From 9c9a90efaa61e2d088480ec7fd3b7c370248d74e Mon Sep 17 00:00:00 2001 From: Kornei Dontsov Date: Wed, 18 Jan 2023 19:09:51 +0300 Subject: [PATCH] Correctly validate the type of loaded UnityNodeProfider asset --- Unity3D/PocoManager.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Unity3D/PocoManager.cs b/Unity3D/PocoManager.cs index eb532ed..d62937f 100644 --- a/Unity3D/PocoManager.cs +++ b/Unity3D/PocoManager.cs @@ -36,16 +36,22 @@ 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(nodeFactoryAssetPath); + var nodeFactoryAssetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(nodeFactoryAssetGuid); + otherNodeProvider = UnityEditor.AssetDatabase.LoadAssetAtPath(nodeFactoryAssetPath); + if (otherNodeProvider) break; + } + + if (otherNodeProvider) + { + nodeProvider = otherNodeProvider; } else { @@ -53,7 +59,7 @@ private void OnValidate() } } } - #endif +#endif void Awake() {