diff --git a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs index 22328be5..ffa10d5a 100644 --- a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs +++ b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System; using UnityEngine.Events; using MarkerMetro.Unity.WinLegacy.Reflection; +using System.Linq; namespace Fungus { @@ -403,14 +404,16 @@ namespace Fungus { static Dictionary types = new Dictionary(); - public static System.Type GetType(string typeName) + public static System.Type GetType(string AssemblyQualifiedNameTypeName) { - if (types.ContainsKey(typeName)) - return types[typeName]; + if (types.ContainsKey(AssemblyQualifiedNameTypeName) && types[AssemblyQualifiedNameTypeName] != null) + return types[AssemblyQualifiedNameTypeName]; - types[typeName] = System.Type.GetType(typeName); + types[AssemblyQualifiedNameTypeName] = AppDomain.CurrentDomain.GetAssemblies(). + SelectMany(x => x.GetTypes()) + .FirstOrDefault(x => x.AssemblyQualifiedName == AssemblyQualifiedNameTypeName); - return types[typeName]; + return types[AssemblyQualifiedNameTypeName]; } } } diff --git a/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs b/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs index 86420cef..feda95ec 100644 --- a/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs +++ b/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs @@ -84,7 +84,17 @@ namespace Fungus.EditorUtils var saveReturnValueProp = objTarget.FindProperty("saveReturnValue"); var returnValueKeyProp = objTarget.FindProperty("returnValueVariableKey"); - var objComponent = gameObject.GetComponent(ReflectionHelper.GetType(component)); + var t = ReflectionHelper.GetType(component); + Component objComponent = null; + if (t != null) + { + objComponent = gameObject.GetComponent(t); + } + else + { + Debug.LogError("InvokeMethod command has attempted to locate a type that cannot be found: " + component); + } + var bindingFlags = BindingFlags.Default | BindingFlags.Public | BindingFlags.Instance; if (!showInheritedProp.boolValue) diff --git a/Assets/FungusExamples/FirstPerson/FirstPersonDemo.unity b/Assets/FungusExamples/FirstPerson/FirstPersonDemo.unity index 28ca771f..14fb21ab 100644 --- a/Assets/FungusExamples/FirstPerson/FirstPersonDemo.unity +++ b/Assets/FungusExamples/FirstPerson/FirstPersonDemo.unity @@ -795,7 +795,7 @@ MonoBehaviour: indentLevel: 0 description: targetObject: {fileID: 1377282257} - targetComponentAssemblyName: Fungus.Examples.LookingAtDoor, Assembly-CSharp, Version=0.0.0.0, + targetComponentAssemblyName: Fungus.Examples.LookingAtDoor, FungusExamples, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null targetComponentFullname: UnityEngine.Component[] targetComponentText: LookingAtDoor