Skip to content

Commit 280e819

Browse files
Merge pull request #12 from CarterGames/pre-release
📦 0.5.4 Release
2 parents 5531ccd + a8d72e5 commit 280e819

File tree

4 files changed

+69
-50
lines changed

4 files changed

+69
-50
lines changed

Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/AssetInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static class AssetInfo
3131
/// <summary>
3232
/// The version number of the asset.
3333
/// </summary>
34-
public static string VersionNumber => "0.5.3";
34+
public static string VersionNumber => "0.5.4";
3535

3636

3737
/// <summary>
@@ -40,6 +40,6 @@ public static class AssetInfo
4040
/// <remarks>
4141
/// Format is Y/M/D.
4242
/// </remarks>
43-
public static string ReleaseDate => "2025/03/23";
43+
public static string ReleaseDate => "2025/03/30";
4444
}
4545
}

Carter Games/Notion Database To Unity/Code/Runtime/Notion/Notion Database Handling/Properties/NotionPropertyMultiSelect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public sealed class NotionPropertyMultiSelect : NotionProperty
6262
public NotionPropertyMultiSelect(NotionPropertyData data)
6363
{
6464
PropertyName = data.propertyName;
65-
InternalValue = (string[]) data.valueForType;
65+
InternalValue = data.valueForType;
6666
JsonValue = data.jsonValue;
6767
DownloadText = data.downloadText;
6868
}

Carter Games/Notion Database To Unity/Code/Runtime/Notion/Notion Database Handling/Value Conversion/NotionPropertyValueHandler.cs

Lines changed: 65 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
using System;
2525
using System.Collections.Generic;
26+
using System.Linq;
2627
using System.Text;
2728
using CarterGames.Standalone.NotionData.Common;
2829
using CarterGames.Standalone.NotionData.ThirdParty;
@@ -47,16 +48,14 @@ public static bool TryGetValueAs(NotionProperty property, Type fieldType, out ob
4748
if (fieldType.IsArray)
4849
{
4950
if (TryParseAsArray(property, fieldType, out value)) return true;
50-
if (TryParseAsList(property, fieldType, out value)) return true;
5151

5252
if (fieldType.IsEnum)
5353
{
5454
if (TryParseEnumOrEnumFlags(property, fieldType, out value)) return true;
5555
}
5656
}
5757

58-
59-
if (fieldType.ToString().Contains("System.Collections.Generic.List"))
58+
if (fieldType.IsGenericList())
6059
{
6160
if (TryParseAsList(property, fieldType, out value)) return true;
6261

@@ -266,67 +265,81 @@ private static bool TryParseAsArray(NotionProperty property, Type fieldType, out
266265
try
267266
{
268267
var data = GetPropertyValueAsCollection(property);
268+
269+
if (fieldType.GetElementType().IsEnum)
270+
{
271+
var parsedStringArray = new string[data.Count];
269272

273+
for (var i = 0; i < data.Count; i++)
274+
{
275+
parsedStringArray[i] = data[i].Value;
276+
}
270277

271-
switch (fieldType.Name)
278+
result = parsedStringArray.Select(t => (int) Enum.Parse(fieldType.GetElementType(), t)).ToArray();
279+
return true;
280+
}
281+
else
272282
{
273-
case { } x when x.Contains("Int"):
283+
switch (fieldType.GetElementType()?.Name)
284+
{
285+
case { } x when x.Equals("Int"):
274286

275-
var parsedIntArray = new int[data.Count];
287+
var parsedIntArray = new int[data.Count];
276288

277-
for (var i = 0; i < data.Count; i++)
278-
{
279-
parsedIntArray[i] = int.Parse(data[i].Value);
280-
}
289+
for (var i = 0; i < data.Count; i++)
290+
{
291+
parsedIntArray[i] = int.Parse(data[i].Value);
292+
}
281293

282-
result = parsedIntArray;
283-
break;
284-
case { } x when x.Contains("Boolean"):
294+
result = parsedIntArray;
295+
break;
296+
case { } x when x.Equals("Boolean"):
285297

286-
var parsedBoolArray = new bool[data.Count];
298+
var parsedBoolArray = new bool[data.Count];
287299

288-
for (var i = 0; i < data.Count; i++)
289-
{
290-
parsedBoolArray[i] = bool.Parse(data[i].Value);
291-
}
300+
for (var i = 0; i < data.Count; i++)
301+
{
302+
parsedBoolArray[i] = bool.Parse(data[i].Value);
303+
}
292304

293-
result = parsedBoolArray;
294-
break;
295-
case { } x when x.Contains("Single"):
305+
result = parsedBoolArray;
306+
break;
307+
case { } x when x.Equals("Single"):
296308

297-
var parsedFloatArray = new float[data.Count];
309+
var parsedFloatArray = new float[data.Count];
298310

299-
for (var i = 0; i < data.Count; i++)
300-
{
301-
parsedFloatArray[i] = float.Parse(data[i].Value);
302-
}
311+
for (var i = 0; i < data.Count; i++)
312+
{
313+
parsedFloatArray[i] = float.Parse(data[i].Value);
314+
}
303315

304-
result = parsedFloatArray;
305-
break;
306-
case { } x when x.Contains("Double"):
316+
result = parsedFloatArray;
317+
break;
318+
case { } x when x.Equals("Double"):
307319

308-
var parsedDoubleArray = new double[data.Count];
320+
var parsedDoubleArray = new double[data.Count];
309321

310-
for (var i = 0; i < data.Count; i++)
311-
{
312-
parsedDoubleArray[i] = double.Parse(data[i].Value);
313-
}
322+
for (var i = 0; i < data.Count; i++)
323+
{
324+
parsedDoubleArray[i] = double.Parse(data[i].Value);
325+
}
314326

315-
result = parsedDoubleArray;
316-
break;
317-
case { } x when x.Contains("String"):
327+
result = parsedDoubleArray;
328+
break;
329+
case { } x when x.Equals("String"):
318330

319-
var parsedStringArray = new string[data.Count];
331+
var parsedStringArray = new string[data.Count];
320332

321-
for (var i = 0; i < data.Count; i++)
322-
{
323-
parsedStringArray[i] = data[i].Value;
324-
}
333+
for (var i = 0; i < data.Count; i++)
334+
{
335+
parsedStringArray[i] = data[i].Value;
336+
}
325337

326-
result = parsedStringArray;
327-
break;
328-
default:
329-
break;
338+
result = parsedStringArray;
339+
break;
340+
default:
341+
break;
342+
}
330343
}
331344

332345
return result != null;
@@ -475,5 +488,11 @@ private static bool TryParseEnumOrEnumFlags(NotionProperty property, Type fieldT
475488
return false;
476489
}
477490
}
491+
492+
493+
private static bool IsGenericList(this Type o)
494+
{
495+
return (o.IsGenericType && (o.GetGenericTypeDefinition() == typeof(List<>)));
496+
}
478497
}
479498
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "games.carter.standalone.notiondata",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"displayName": "Notion Data (Standalone)",
55
"description": "A system to import Notion databases into a Unity scriptable object for use in Unity projects. This is a standalone version of the system in the Cart library of the same name.",
66
"unity": "2020.3",

0 commit comments

Comments
 (0)