Skip to content

Commit

Permalink
Correctly validate the type of loaded UnityNodeProfider asset
Browse files Browse the repository at this point in the history
  • Loading branch information
KorneiDontsov committed Jan 18, 2023
1 parent 3a05265 commit 9c9a90e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Unity3D/PocoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,30 @@ class RPC : Attribute
{
}

#if UNITY_EDITOR
#if UNITY_EDITOR
private void OnValidate()
{
if (!nodeProvider)
{
string[] nodeFactories = UnityEditor.AssetDatabase.FindAssets("t:UnityNodeProvider");
if (nodeFactories.Length > 0)
UnityNodeProvider otherNodeProvider = null;
foreach (var nodeFactoryAssetGuid in UnityEditor.AssetDatabase.FindAssets("t:UnityNodeProvider"))
{
var nodeFactoryAssetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(nodeFactories[0]);
nodeProvider = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityNodeProvider>(nodeFactoryAssetPath);
var nodeFactoryAssetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(nodeFactoryAssetGuid);
otherNodeProvider = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityNodeProvider>(nodeFactoryAssetPath);
if (otherNodeProvider) break;
}

if (otherNodeProvider)
{
nodeProvider = otherNodeProvider;
}
else
{
Debug.LogError("Failed to find UnityNodeProvider for Poco.");
}
}
}
#endif
#endif

void Awake()
{
Expand Down

0 comments on commit 9c9a90e

Please sign in to comment.