Skip to content

Commit

Permalink
🔧 More enum parsing issue fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMCarter committed Sep 10, 2024
1 parent b96cc83 commit 9d90146
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public void OnInspectorSettingsGUI()

EditorGUILayout.PropertyField(SettingsDef.ObjectRef.Fp("apiVersion"));
EditorGUILayout.PropertyField(SettingsDef.ObjectRef.Fp("apiReleaseVersion"));
EditorGUILayout.PropertyField(SettingsDef.ObjectRef.Fp("notionApiKey"), AssetMeta.GetData("NotionData").Content("notion_defaultAPIKey"));

if (EditorGUI.EndChangeCheck())
{
Expand Down Expand Up @@ -104,8 +103,6 @@ public void OnProjectSettingsGUI()

EditorGUILayout.PropertyField(SettingsDef.ObjectRef.Fp("apiVersion"));
EditorGUILayout.PropertyField(SettingsDef.ObjectRef.Fp("apiReleaseVersion"));
EditorGUILayout.PropertyField(SettingsDef.ObjectRef.Fp("notionApiKey"), AssetMeta.GetData("NotionData").Content("notion_defaultAPIKey"));


if (EditorGUI.EndChangeCheck())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ namespace CarterGames.Cart.Modules.NotionData.Editor
{
public static class NotionMetaData
{
public static readonly GUIContent VersionNumber =
new GUIContent(
"Version:",
"The version number for the standalone asset.");


public static readonly GUIContent ReleaseDate =
new GUIContent(
"Release date (Y/M/D):",
"The release date of the standalone asset. In Year/Month/Day order.");


public static readonly GUIContent ApiVersion =
new GUIContent(
"API version:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public sealed class DataAssetSettingsNotionData : DataAsset

[SerializeField] private NotionApiVersion apiVersion;
[SerializeField] private NotionApiReleaseVersion apiReleaseVersion;
[SerializeField] private string notionApiKey;

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Properties
Expand All @@ -56,12 +55,6 @@ public sealed class DataAssetSettingsNotionData : DataAsset
/// The Notion API version to use.
/// </summary>
public NotionApiVersion NotionApiVersion => apiVersion;


/// <summary>
/// Gets the notion secret api key for use with the notion data asset system.
/// </summary>
public string NotionApiKey => notionApiKey;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ public object GetValueAs(Type fieldType)
{
var combined = string.Empty;
var elements = JSON.Parse(propertyValue).AsArray;

if (elements.Count <= 1)
{
return Enum.Parse(fieldType, elements[0].Value.Replace(" ", ""));
}

for (var index = 0; index < elements.Count; index++)
{
Expand All @@ -148,7 +153,16 @@ public object GetValueAs(Type fieldType)
}
else
{
return Enum.Parse(fieldType, propertyValue.Replace(" ", ""));
try
{
return Enum.Parse(fieldType, propertyValue.Replace(" ", ""));
}
#pragma warning disable
catch (Exception e)
#pragma warning restore
{
return fieldType.IsValueType ? Activator.CreateInstance(fieldType) : null;
}
}
}

Expand Down

0 comments on commit 9d90146

Please sign in to comment.