diff --git a/Assets/Fungus/Flowchart/Editor/InvokeEditor.cs b/Assets/Fungus/Flowchart/Editor/InvokeEventEditor.cs similarity index 85% rename from Assets/Fungus/Flowchart/Editor/InvokeEditor.cs rename to Assets/Fungus/Flowchart/Editor/InvokeEventEditor.cs index 702cefbb..d8471fc5 100644 --- a/Assets/Fungus/Flowchart/Editor/InvokeEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/InvokeEventEditor.cs @@ -5,8 +5,8 @@ using System.Collections.Generic; namespace Fungus { - [CustomEditor (typeof(Invoke))] - public class InvokeEditor : CommandEditor + [CustomEditor (typeof(InvokeEvent))] + public class InvokeEventEditor : CommandEditor { protected SerializedProperty delayProp; protected SerializedProperty invokeTypeProp; @@ -42,24 +42,24 @@ namespace Fungus EditorGUILayout.PropertyField(delayProp); EditorGUILayout.PropertyField(invokeTypeProp); - switch ((Invoke.InvokeType)invokeTypeProp.enumValueIndex) + switch ((InvokeEvent.InvokeType)invokeTypeProp.enumValueIndex) { - case Invoke.InvokeType.Static: + case InvokeEvent.InvokeType.Static: EditorGUILayout.PropertyField(staticEventProp); break; - case Invoke.InvokeType.DynamicBoolean: + case InvokeEvent.InvokeType.DynamicBoolean: EditorGUILayout.PropertyField(booleanEventProp); EditorGUILayout.PropertyField(booleanParameterProp); break; - case Invoke.InvokeType.DynamicInteger: + case InvokeEvent.InvokeType.DynamicInteger: EditorGUILayout.PropertyField(integerEventProp); EditorGUILayout.PropertyField(integerParameterProp); break; - case Invoke.InvokeType.DynamicFloat: + case InvokeEvent.InvokeType.DynamicFloat: EditorGUILayout.PropertyField(floatEventProp); EditorGUILayout.PropertyField(floatParameterProp); break; - case Invoke.InvokeType.DynamicString: + case InvokeEvent.InvokeType.DynamicString: EditorGUILayout.PropertyField(stringEventProp); EditorGUILayout.PropertyField(stringParameterProp); break; diff --git a/Assets/Fungus/Flowchart/Editor/InvokeEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/InvokeEventEditor.cs.meta similarity index 76% rename from Assets/Fungus/Flowchart/Editor/InvokeEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/InvokeEventEditor.cs.meta index 24e0fa99..86785628 100644 --- a/Assets/Fungus/Flowchart/Editor/InvokeEditor.cs.meta +++ b/Assets/Fungus/Flowchart/Editor/InvokeEventEditor.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 1de123a9a8da54ff49b112d39101366b -timeCreated: 1437051529 +guid: 04b135d1f6a7a40429648cb2ac86ba0b +timeCreated: 1439371705 licenseType: Free MonoImporter: serializedVersion: 2 diff --git a/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs b/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs new file mode 100755 index 00000000..7d8fee5b --- /dev/null +++ b/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs @@ -0,0 +1,442 @@ +using UnityEngine; +using System.Collections; +using UnityEditor; +using System.Linq; +using System.Reflection; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Fungus +{ + + [CustomEditor(typeof(InvokeMethod))] + public class InvokeMethodEditor : CommandEditor + { + InvokeMethod targetMethod; + + public override void DrawCommandGUI() + { + base.DrawCommandGUI(); + + targetMethod = target as InvokeMethod; + + if (targetMethod == null || targetMethod.targetObject == null) + return; + + SerializedObject objSerializedTarget = new SerializedObject(targetMethod); + + string component = ShowComponents(objSerializedTarget, targetMethod.targetObject); + + // show component methods if selected + if (!string.IsNullOrEmpty(component)) + { + var method = ShowMethods(objSerializedTarget, targetMethod.targetObject, component); + + // show method parameters if selected + if (method != null) + { + objSerializedTarget.ApplyModifiedProperties(); + ShowParameters(objSerializedTarget, targetMethod.targetObject, method); + ShowReturnValue(objSerializedTarget, method); + } + } + } + + private string ShowComponents(SerializedObject objTarget, GameObject gameObject) + { + var targetComponentAssemblyName = objTarget.FindProperty("targetComponentAssemblyName"); + var targetComponentFullname = objTarget.FindProperty("targetComponentFullname"); + var targetComponentText = objTarget.FindProperty("targetComponentText"); + var objComponents = gameObject.GetComponents(); + var objTypesAssemblynames = (from objComp in objComponents select objComp.GetType().AssemblyQualifiedName).ToList(); + var objTypesName = (from objComp in objComponents select objComp.GetType().Name).ToList(); + + int index = objTypesAssemblynames.IndexOf(targetComponentAssemblyName.stringValue); + + index = EditorGUILayout.Popup("Target Component", index, objTypesName.ToArray()); + + if (index != -1) + { + targetComponentAssemblyName.stringValue = objTypesAssemblynames[index]; + targetComponentFullname.stringValue = objComponents.GetType().FullName; + targetComponentText.stringValue = objTypesName[index]; + } + else + { + targetComponentAssemblyName.stringValue = null; + } + + objTarget.ApplyModifiedProperties(); + + return targetComponentAssemblyName.stringValue; + } + + private MethodInfo ShowMethods(SerializedObject objTarget, GameObject gameObject, string component) + { + MethodInfo result = null; + + var targetMethodProp = objTarget.FindProperty("targetMethod"); + var targetMethodTextProp = objTarget.FindProperty("targetMethodText"); + var methodParametersProp = objTarget.FindProperty("methodParameters"); + var showInheritedProp = objTarget.FindProperty("showInherited"); + var saveReturnValueProp = objTarget.FindProperty("saveReturnValue"); + var returnValueKeyProp = objTarget.FindProperty("returnValueVariableKey"); + + var objComponent = gameObject.GetComponent(ReflectionHelper.GetType(component)); + var bindingFlags = BindingFlags.Default | BindingFlags.Public | BindingFlags.Instance; + + if (!showInheritedProp.boolValue) + { + bindingFlags |= BindingFlags.DeclaredOnly; + } + + if (objComponent != null) + { + var objMethods = objComponent.GetType().GetMethods(bindingFlags); + var methods = (from objMethod in objMethods where !objMethod.IsSpecialName select objMethod).ToList(); // filter out the getter/setter methods + var methodText = (from objMethod in methods select objMethod.Name + FormatParameters(objMethod.GetParameters()) + ": " + objMethod.ReturnType.Name).ToList(); + int index = methodText.IndexOf(targetMethodTextProp.stringValue); + + index = EditorGUILayout.Popup("Target Method", index, methodText.ToArray()); + + EditorGUILayout.PropertyField(showInheritedProp); + + if (index != -1) + { + if (targetMethodTextProp.stringValue != methodText[index]) + { + // reset + methodParametersProp.ClearArray(); + methodParametersProp.arraySize = methods[index].GetParameters().Length; + + saveReturnValueProp.boolValue = false; + returnValueKeyProp.stringValue = null; + } + + targetMethodTextProp.stringValue = methodText[index]; + targetMethodProp.stringValue = methods[index].Name; + + result = methods[index]; + } + else + { + targetMethodTextProp.stringValue = null; + targetMethodProp.stringValue = null; + } + + objTarget.ApplyModifiedProperties(); + } + + return result; + } + + private void ShowParameters(SerializedObject objTarget, GameObject gameObject, MethodInfo method) + { + var methodParametersProp = objTarget.FindProperty("methodParameters"); + var objParams = method.GetParameters(); + + if (objParams.Length > 0) + { + GUILayout.Space(20); + EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel); + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + + for (int i = 0; i < objParams.Length; i++) + { + var objParam = objParams[i]; + + GUILayout.BeginHorizontal(); + string labelFormat = string.Format("{0}: {1}", objParam.ParameterType.Name, objParam.Name); + + var objItemProp = methodParametersProp.GetArrayElementAtIndex(i); + var serObjValueProp = objItemProp.FindPropertyRelative("objValue"); + var serVariableKeyProp = objItemProp.FindPropertyRelative("variableKey"); + var serValueTypeAssemblynameProp = serObjValueProp.FindPropertyRelative("typeAssemblyname"); + var serValueTypeFullnameProp = serObjValueProp.FindPropertyRelative("typeFullname"); + + serValueTypeAssemblynameProp.stringValue = objParam.ParameterType.AssemblyQualifiedName; + serValueTypeFullnameProp.stringValue = objParam.ParameterType.FullName; + + bool isDrawn = true; + + if (string.IsNullOrEmpty(serVariableKeyProp.stringValue)) + { + isDrawn = DrawTypedPropertyInput(labelFormat, serObjValueProp, objParam.ParameterType); + } + + if (isDrawn) + { + var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().variables, objParam.ParameterType); + var values = new string[] { "" }; + var displayValue = values.Concat(vars).ToList(); + + int index = displayValue.IndexOf(serVariableKeyProp.stringValue); + + if (index == -1) + { + index = 0; + } + + if (string.IsNullOrEmpty(serVariableKeyProp.stringValue)) + { + index = EditorGUILayout.Popup(index, displayValue.ToArray(), GUILayout.MaxWidth(80)); + } + else + { + index = EditorGUILayout.Popup(labelFormat, index, displayValue.ToArray()); + } + + if (index > 0) + { + serVariableKeyProp.stringValue = displayValue[index]; + } + else + { + serVariableKeyProp.stringValue = null; + } + } + else + { + var style = EditorStyles.label; + var prevColor = style.normal.textColor; + style.normal.textColor = Color.red; + EditorGUILayout.LabelField(new GUIContent(objParam.ParameterType.Name + " cannot be drawn, don´t use this method in the flowchart."), style); + style.normal.textColor = prevColor; + } + + GUILayout.EndHorizontal(); + } + EditorGUILayout.EndVertical(); + + objTarget.ApplyModifiedProperties(); + } + } + + private void ShowReturnValue(SerializedObject objTarget, MethodInfo method) + { + var saveReturnValueProp = objTarget.FindProperty("saveReturnValue"); + var returnValueKeyProp = objTarget.FindProperty("returnValueVariableKey"); + var returnValueTypeProp = objTarget.FindProperty("returnValueType"); + var callModeProp = objTarget.FindProperty("callMode"); + + returnValueTypeProp.stringValue = method.ReturnType.FullName; + + if (method.ReturnType == typeof(IEnumerator)) + { + GUILayout.Space(20); + EditorGUILayout.PropertyField(callModeProp); + } + else if (method.ReturnType != typeof(void)) + { + GUILayout.Space(20); + EditorGUILayout.LabelField("Return Value", EditorStyles.boldLabel); + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + saveReturnValueProp.boolValue = EditorGUILayout.Toggle("Save return value", saveReturnValueProp.boolValue); + + if (saveReturnValueProp.boolValue) + { + var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().variables, method.ReturnType).ToList(); + int index = vars.IndexOf(returnValueKeyProp.stringValue); + index = EditorGUILayout.Popup(method.ReturnType.Name, index, vars.ToArray()); + + if (index != -1) + { + returnValueKeyProp.stringValue = vars[index]; + } + } + + EditorGUILayout.EndVertical(); + } + else + { + saveReturnValueProp.boolValue = false; + } + + objTarget.ApplyModifiedProperties(); + } + + private bool DrawTypedPropertyInput(string label, SerializedProperty objProperty, Type type) + { + SerializedProperty objectValue = null; + + if (type == typeof(int)) + { + objectValue = objProperty.FindPropertyRelative("intValue"); + objectValue.intValue = EditorGUILayout.IntField(new GUIContent(label), objectValue.intValue); + + return true; + } + else if (type == typeof(bool)) + { + objectValue = objProperty.FindPropertyRelative("boolValue"); + objectValue.boolValue = EditorGUILayout.Toggle(new GUIContent(label), objectValue.boolValue); + + return true; + } + else if (type == typeof(float)) + { + objectValue = objProperty.FindPropertyRelative("floatValue"); + objectValue.floatValue = EditorGUILayout.FloatField(new GUIContent(label), objectValue.floatValue); + + return true; + } + else if (type == typeof(string)) + { + objectValue = objProperty.FindPropertyRelative("stringValue"); + objectValue.stringValue = EditorGUILayout.TextField(new GUIContent(label), objectValue.stringValue); + + return true; + } + else if (type == typeof(Color)) + { + objectValue = objProperty.FindPropertyRelative("colorValue"); + objectValue.colorValue = EditorGUILayout.ColorField(new GUIContent(label), objectValue.colorValue); + + return true; + } + else if (type == typeof(UnityEngine.GameObject)) + { + objectValue = objProperty.FindPropertyRelative("gameObjectValue"); + objectValue.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(label), objectValue.objectReferenceValue, typeof(UnityEngine.GameObject), true); + + return true; + } + else if (type == typeof(UnityEngine.Material)) + { + objectValue = objProperty.FindPropertyRelative("materialValue"); + objectValue.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(label), objectValue.objectReferenceValue, typeof(UnityEngine.Material), true); + + return true; + } + else if (type == typeof(UnityEngine.Sprite)) + { + objectValue = objProperty.FindPropertyRelative("spriteValue"); + objectValue.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(label), objectValue.objectReferenceValue, typeof(UnityEngine.Sprite), true); + + return true; + } + else if (type == typeof(UnityEngine.Texture)) + { + objectValue = objProperty.FindPropertyRelative("textureValue"); + objectValue.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(label), objectValue.objectReferenceValue, typeof(UnityEngine.Texture), true); + + return true; + } + else if (type == typeof(UnityEngine.Vector2)) + { + objectValue = objProperty.FindPropertyRelative("vector2Value"); + objectValue.vector2Value = EditorGUILayout.Vector2Field(new GUIContent(label), objectValue.vector2Value); + + return true; + } + else if (type == typeof(UnityEngine.Vector3)) + { + objectValue = objProperty.FindPropertyRelative("vector3Value"); + objectValue.vector3Value = EditorGUILayout.Vector3Field(new GUIContent(label), objectValue.vector3Value); + + return true; + } + else if (type.IsSubclassOf(typeof(UnityEngine.Object))) + { + objectValue = objProperty.FindPropertyRelative("objectValue"); + objectValue.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(label), objectValue.objectReferenceValue, type, true); + + return true; + } + else if (type.IsEnum) + { + var enumNames = Enum.GetNames(type); + objectValue = objProperty.FindPropertyRelative("intValue"); + objectValue.intValue = EditorGUILayout.Popup(label, objectValue.intValue, enumNames); + + return true; + } + + return false; + } + + private string[] GetFungusVariablesByType(List variables, Type type) + { + string[] result = new string[0]; + + if (type == typeof(int)) + { + result = (from v in variables where v.GetType() == typeof(IntegerVariable) select v.key).ToArray(); + } + else if (type == typeof(bool)) + { + result = (from v in variables where v.GetType() == typeof(BooleanVariable) select v.key).ToArray(); + } + else if (type == typeof(float)) + { + result = (from v in variables where v.GetType() == typeof(FloatVariable) select v.key).ToArray(); + } + else if (type == typeof(string)) + { + result = (from v in variables where v.GetType() == typeof(StringVariable) select v.key).ToArray(); + } + else if (type == typeof(Color)) + { + result = (from v in variables where v.GetType() == typeof(ColorVariable) select v.key).ToArray(); + } + else if (type == typeof(UnityEngine.GameObject)) + { + result = (from v in variables where v.GetType() == typeof(GameObjectVariable) select v.key).ToArray(); + } + else if (type == typeof(UnityEngine.Material)) + { + result = (from v in variables where v.GetType() == typeof(MaterialVariable) select v.key).ToArray(); + } + else if (type == typeof(UnityEngine.Sprite)) + { + result = (from v in variables where v.GetType() == typeof(SpriteVariable) select v.key).ToArray(); + } + else if (type == typeof(UnityEngine.Texture)) + { + result = (from v in variables where v.GetType() == typeof(TextureVariable) select v.key).ToArray(); + } + else if (type == typeof(UnityEngine.Vector2)) + { + result = (from v in variables where v.GetType() == typeof(Vector2Variable) select v.key).ToArray(); + } + else if (type == typeof(UnityEngine.Vector3)) + { + result = (from v in variables where v.GetType() == typeof(Vector3Variable) select v.key).ToArray(); + } + else if (type.IsSubclassOf(typeof(UnityEngine.Object))) + { + result = (from v in variables where v.GetType() == typeof(ObjectVariable) select v.key).ToArray(); + } + + return result; + } + + private string FormatParameters(ParameterInfo[] paramInfo) + { + string result = " ("; + + for (int i = 0; i < paramInfo.Length; i++) + { + var pi = paramInfo[i]; + result += pi.ParameterType.Name; // " arg" + (i + 1); + + if (i < paramInfo.Length - 1) + { + result += ", "; + } + } + + return result + ")"; + } + + private object GetDefaultValue(Type t) + { + if (t.IsValueType) + return Activator.CreateInstance(t); + + return null; + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs.meta new file mode 100644 index 00000000..e7adda6e --- /dev/null +++ b/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 79f9520ae0b21494caa8f8bc97a2db9d +timeCreated: 1439307700 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Invoke.cs b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs similarity index 91% rename from Assets/Fungus/Flowchart/Scripts/Commands/Invoke.cs rename to Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs index f3f0b16a..282b7b9b 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Invoke.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs @@ -6,13 +6,14 @@ using UnityEngine.Events; namespace Fungus { [CommandInfo("Scripting", - "Invoke", - "Calls a list of methods via the Unity UI EventSystem.")] + "Invoke Event", + "Calls a list of component methods via the Unity Event System (as used in the Unity UI). " + + "This command is more efficient than the Invoke Method command but can only pass a single parameter and doesn't support return values.")] [AddComponentMenu("")] // This command uses the UnityEvent system to call methods in script. // http://docs.unity3d.com/Manual/UnityEvents.html - public class Invoke : Command + public class InvokeEvent : Command { [Serializable] public class BooleanEvent : UnityEvent {} [Serializable] public class IntegerEvent : UnityEvent {} diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Invoke.cs.meta b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs.meta similarity index 100% rename from Assets/Fungus/Flowchart/Scripts/Commands/Invoke.cs.meta rename to Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs.meta diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs new file mode 100755 index 00000000..8934aeef --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs @@ -0,0 +1,403 @@ +using UnityEngine; +using System.Collections; +using System.Reflection; +using System.Linq; +using System.Collections.Generic; +using System; +using UnityEngine.Events; + +namespace Fungus +{ + + [CommandInfo("Scripting", + "Invoke Method", + "Invokes a method of a component via reflection. Supports passing multiple parameters and storing returned values in a Fungus variable.")] + public class InvokeMethod : Command + { + [Tooltip("Delay before invoking method")] + public float delay; + + [Tooltip("GameObject containing the component method to be invoked")] + public GameObject targetObject; + + [HideInInspector] + [Tooltip("Name of assembly containing the target component")] + public string targetComponentAssemblyName; + + [HideInInspector] + [Tooltip("Full name of the target component")] + public string targetComponentFullname; + + [HideInInspector] + [Tooltip("Display name of the target component")] + public string targetComponentText; + + [HideInInspector] + [Tooltip("Name of target method to invoke on the target component")] + public string targetMethod; + + [HideInInspector] + [Tooltip("Display name of target method to invoke on the target component")] + public string targetMethodText; + + [HideInInspector] + [Tooltip("List of parameters to pass to the invoked method")] + public InvokeMethodParameter[] methodParameters; + + [HideInInspector] + [Tooltip("If true, store the return value in a flowchart variable of the same type.")] + public bool saveReturnValue; + + [HideInInspector] + [Tooltip("Name of Fungus variable to store the return value in")] + public string returnValueVariableKey; + + [HideInInspector] + [Tooltip("The type of the return value")] + public string returnValueType; + + [HideInInspector] + [Tooltip("If true, list all inherited methods for the component")] + public bool showInherited; + + [HideInInspector] + [Tooltip("The coroutine call behavior for methods that return IEnumerator")] + public Fungus.Call.CallMode callMode; + + protected Type componentType; + protected Component objComponent; + protected Type[] parameterTypes = null; + protected MethodInfo objMethod; + + protected virtual void Awake() + { + if (componentType == null) + { + componentType = ReflectionHelper.GetType(targetComponentAssemblyName); + } + + if (objComponent == null) + { + objComponent = targetObject.GetComponent(componentType); + } + + if (parameterTypes == null) + { + parameterTypes = GetParameterTypes(); + } + + if (objMethod == null) + { + objMethod = UnityEvent.GetValidMethodInfo(objComponent, targetMethod, parameterTypes); + } + } + + public override void OnEnter() + { + if (delay <= 0) + { + DoInvokeMethod(); + } + else + { + Invoke("DoInvokeMethod", delay); + } + } + + protected virtual void DoInvokeMethod() + { + try + { + if (targetObject == null || string.IsNullOrEmpty(targetComponentAssemblyName) || string.IsNullOrEmpty(targetMethod)) + { + Continue(); + return; + } + + if (returnValueType != "System.Collections.IEnumerator") + { + var objReturnValue = objMethod.Invoke(objComponent, GetParameterValues()); + + if (saveReturnValue) + { + SetVariable(returnValueVariableKey, objReturnValue, returnValueType); + } + + Continue(); + } + else + { + StartCoroutine(ExecuteCoroutine()); + + if(callMode == Call.CallMode.Continue) + { + Continue(); + } + else if(callMode == Call.CallMode.Stop) + { + Stop(); + } + } + } + catch (System.Exception ex) + { + Debug.LogError("Error: " + ex.Message); + } + } + + protected virtual IEnumerator ExecuteCoroutine() + { + yield return StartCoroutine((IEnumerator)objMethod.Invoke(objComponent, GetParameterValues())); + + if (callMode == Call.CallMode.WaitUntilFinished) + { + Continue(); + } + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + + public override string GetSummary() + { + if (targetObject == null) + { + return "Error: targetObject is not assigned"; + } + + return targetObject.name + "." + targetComponentText + "." + targetMethodText; + } + + protected System.Type[] GetParameterTypes() + { + System.Type[] types = new System.Type[methodParameters.Length]; + + for (int i = 0; i < methodParameters.Length; i++) + { + var item = methodParameters[i]; + var objType = ReflectionHelper.GetType(item.objValue.typeAssemblyname); + + types[i] = objType; + } + + return types; + } + + protected object[] GetParameterValues() + { + object[] values = new object[methodParameters.Length]; + var flowChart = GetFlowchart(); + + for (int i = 0; i < methodParameters.Length; i++) + { + var item = methodParameters[i]; + + if (string.IsNullOrEmpty(item.variableKey)) + { + values[i] = item.objValue.GetValue(); + } + else + { + object objValue = null; + + switch (item.objValue.typeFullname) + { + case "System.Int32": + objValue = flowChart.GetIntegerVariable(item.variableKey); + break; + case "System.Boolean": + objValue = flowChart.GetBooleanVariable(item.variableKey); + break; + case "System.Single": + objValue = flowChart.GetFloatVariable(item.variableKey); + break; + case "System.String": + objValue = flowChart.GetStringVariable(item.variableKey); + break; + case "UnityEngine.Color": + var color = flowChart.GetVariable(item.variableKey); + if (color != null) + objValue = color.value; + break; + case "UnityEngine.GameObject": + var gameObject = flowChart.GetVariable(item.variableKey); + if (gameObject != null) + objValue = gameObject.value; + break; + case "UnityEngine.Material": + var material = flowChart.GetVariable(item.variableKey); + if (material != null) + objValue = material.value; + break; + case "UnityEngine.Sprite": + var sprite = flowChart.GetVariable(item.variableKey); + if (sprite != null) + objValue = sprite.value; + break; + case "UnityEngine.Texture": + var texture = flowChart.GetVariable(item.variableKey); + if (texture != null) + objValue = texture.value; + break; + case "UnityEngine.Vector2": + var vector2 = flowChart.GetVariable(item.variableKey); + if (vector2 != null) + objValue = vector2.value; + break; + case "UnityEngine.Vector3": + var vector3 = flowChart.GetVariable(item.variableKey); + if (vector3 != null) + objValue = vector3.value; + break; + default: + var obj = flowChart.GetVariable(item.variableKey); + if (obj != null) + objValue = obj.value; + break; + } + + values[i] = objValue; + } + } + + return values; + } + + protected void SetVariable(string key, object value, string returnType) + { + var flowChart = GetFlowchart(); + + switch (returnType) + { + case "System.Int32": + flowChart.SetIntegerVariable(key, (int)value); + break; + case "System.Boolean": + flowChart.SetBooleanVariable(key, (bool)value); + break; + case "System.Single": + flowChart.SetFloatVariable(key, (float)value); + break; + case "System.String": + flowChart.SetStringVariable(key, (string)value); + break; + case "UnityEngine.Color": + flowChart.GetVariable(key).value = (UnityEngine.Color)value; + break; + case "UnityEngine.GameObject": + flowChart.GetVariable(key).value = (UnityEngine.GameObject)value; + break; + case "UnityEngine.Material": + flowChart.GetVariable(key).value = (UnityEngine.Material)value; + break; + case "UnityEngine.Sprite": + flowChart.GetVariable(key).value = (UnityEngine.Sprite)value; + break; + case "UnityEngine.Texture": + flowChart.GetVariable(key).value = (UnityEngine.Texture)value; + break; + case "UnityEngine.Vector2": + flowChart.GetVariable(key).value = (UnityEngine.Vector2)value; + break; + case "UnityEngine.Vector3": + flowChart.GetVariable(key).value = (UnityEngine.Vector3)value; + break; + default: + flowChart.GetVariable(key).value = (UnityEngine.Object)value; + break; + } + } + } + + [System.Serializable] + public class InvokeMethodParameter + { + [SerializeField] + public ObjectValue objValue; + + + [SerializeField] + public string variableKey; + } + + [System.Serializable] + public class ObjectValue + { + public string typeAssemblyname; + public string typeFullname; + + public int intValue; + public bool boolValue; + public float floatValue; + public string stringValue; + + public Color colorValue; + public GameObject gameObjectValue; + public Material materialValue; + public UnityEngine.Object objectValue; + public Sprite spriteValue; + public Texture textureValue; + public Vector2 vector2Value; + public Vector3 vector3Value; + + public object GetValue() + { + switch (typeFullname) + { + case "System.Int32": + return intValue; + case "System.Boolean": + return boolValue; + case "System.Single": + return floatValue; + case "System.String": + return stringValue; + case "UnityEngine.Color": + return colorValue; + case "UnityEngine.GameObject": + return gameObjectValue; + case "UnityEngine.Material": + return materialValue; + case "UnityEngine.Sprite": + return spriteValue; + case "UnityEngine.Texture": + return textureValue; + case "UnityEngine.Vector2": + return vector2Value; + case "UnityEngine.Vector3": + return vector3Value; + default: + var objType = ReflectionHelper.GetType(typeAssemblyname); + + if (objType.IsSubclassOf(typeof(UnityEngine.Object))) + { + return objectValue; + } + else if (objType.IsEnum) + return System.Enum.ToObject(objType, intValue); + + break; + } + + return null; + } + } + + public static class ReflectionHelper + { + static Dictionary types = new Dictionary(); + + public static System.Type GetType(string typeName) + { + if (types.ContainsKey(typeName)) + return types[typeName]; + + types[typeName] = System.Type.GetType(typeName); + + return types[typeName]; + } + } + +} diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs.meta b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs.meta new file mode 100644 index 00000000..6d0e4485 --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 688e35811870d403f9e2b1ab2a699d98 +timeCreated: 1439307694 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Scripting.meta b/Assets/Tests/Scripting.meta new file mode 100644 index 00000000..d94fbf79 --- /dev/null +++ b/Assets/Tests/Scripting.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a2fb91ead9b574717b37022fc3669fe2 +folderAsset: yes +timeCreated: 1439306621 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Scripting/Scripting.unity b/Assets/Tests/Scripting/Scripting.unity new file mode 100644 index 00000000..cbae88e0 --- /dev/null +++ b/Assets/Tests/Scripting/Scripting.unity @@ -0,0 +1,1098 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &338809961 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 338809963} + - 114: {fileID: 338809962} + m_Layer: 0 + m_Name: TestRunner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &338809962 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 338809961} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5c3afc1c624179749bcdecf7b0224902, type: 3} + m_Name: + m_EditorClassIdentifier: + currentTest: {fileID: 0} +--- !u!4 &338809963 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 338809961} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 +--- !u!1 &646902073 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 646902075} + - 114: {fileID: 646902074} + m_Layer: 0 + m_Name: _FungusState + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &646902074 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 646902073} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3} + m_Name: + m_EditorClassIdentifier: + selectedFlowchart: {fileID: 1618689129} +--- !u!4 &646902075 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 646902073} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &756526316 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 756526321} + - 20: {fileID: 756526320} + - 92: {fileID: 756526319} + - 124: {fileID: 756526318} + - 81: {fileID: 756526317} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &756526317 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 756526316} + m_Enabled: 1 +--- !u!124 &756526318 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 756526316} + m_Enabled: 1 +--- !u!92 &756526319 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 756526316} + m_Enabled: 1 +--- !u!20 &756526320 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 756526316} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &756526321 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 756526316} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &1384749029 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1384749030} + - 114: {fileID: 1384749031} + m_Layer: 0 + m_Name: TestInvoke + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &1384749030 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1384749029} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1618689133} + - {fileID: 1960615185} + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!114 &1384749031 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1384749029} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3} + m_Name: + m_EditorClassIdentifier: + timeout: 5 + ignored: 0 + succeedAfterAllAssertionsAreExecuted: 0 + expectException: 0 + expectedExceptionList: + succeedWhenExceptionIsThrown: 0 + includedPlatforms: -1 + platformsToIgnore: [] + dynamic: 0 + dynamicTypeName: +--- !u!1 &1618689128 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1618689133} + - 114: {fileID: 1618689129} + - 114: {fileID: 1618689131} + - 114: {fileID: 1618689132} + - 114: {fileID: 1618689138} + - 114: {fileID: 1618689139} + - 114: {fileID: 1618689134} + - 114: {fileID: 1618689135} + - 114: {fileID: 1618689136} + - 114: {fileID: 1618689137} + - 114: {fileID: 1618689130} + - 114: {fileID: 1618689141} + - 114: {fileID: 1618689142} + - 114: {fileID: 1618689145} + - 114: {fileID: 1618689146} + - 114: {fileID: 1618689144} + - 114: {fileID: 1618689143} + - 114: {fileID: 1618689147} + - 114: {fileID: 1618689149} + - 114: {fileID: 1618689148} + - 114: {fileID: 1618689150} + - 114: {fileID: 1618689140} + m_Layer: 0 + m_Name: Flowchart + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1618689129 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 1.0 + scrollPos: {x: 0, y: 0} + variablesScrollPos: {x: 0, y: 0} + variablesExpanded: 1 + blockViewHeight: 400 + zoom: 1 + scrollViewRect: + serializedVersion: 2 + x: -350 + y: -351 + width: 1161 + height: 873 + selectedBlock: {fileID: 1618689147} + selectedCommands: [] + variables: + - {fileID: 1618689138} + - {fileID: 1618689141} + - {fileID: 1618689144} + - {fileID: 1618689143} + description: + stepPause: 0 + colorCommands: 1 + hideComponents: 1 + saveSelection: 1 + localizationId: +--- !u!114 &1618689130 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 7 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestCall + targetMethodText: 'TestCall (Boolean, Int32, Single, String): Boolean' + methodParameters: + - objValue: + typeAssemblyname: System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.Boolean + intValue: 0 + boolValue: 1 + floatValue: 0 + stringValue: + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + - objValue: + typeAssemblyname: System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.Int32 + intValue: 10 + boolValue: 0 + floatValue: 0 + stringValue: + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + - objValue: + typeAssemblyname: System.Single, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.Single + intValue: 0 + boolValue: 0 + floatValue: 5.19999981 + stringValue: + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + - objValue: + typeAssemblyname: System.String, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.String + intValue: 0 + boolValue: 0 + floatValue: 0 + stringValue: ok + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + saveReturnValue: 1 + returnValueVariableKey: BoolVar + returnValueType: System.Boolean + showInherited: 0 + callMode: 0 +--- !u!114 &1618689131 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 69 + y: 69 + width: 120 + height: 40 + itemId: 0 + blockName: Test Invoke + description: + eventHandler: {fileID: 1618689132} + commandList: + - {fileID: 1618689139} + - {fileID: 1618689137} + - {fileID: 1618689136} + - {fileID: 1618689135} + - {fileID: 1618689134} + - {fileID: 1618689130} + - {fileID: 1618689142} + - {fileID: 1618689146} + - {fileID: 1618689145} + - {fileID: 1618689150} +--- !u!114 &1618689132 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3} + m_Name: + m_EditorClassIdentifier: + parentBlock: {fileID: 1618689131} +--- !u!4 &1618689133 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1384749030} + m_RootOrder: 0 +--- !u!114 &1618689134 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 3 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestCall + targetMethodText: 'TestCall (String): Void' + methodParameters: + - objValue: + typeAssemblyname: System.String, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.String + intValue: 0 + boolValue: 0 + floatValue: 0 + stringValue: ok + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!114 &1618689135 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 4 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestCall + targetMethodText: 'TestCall (Single): Void' + methodParameters: + - objValue: + typeAssemblyname: System.Single, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.Single + intValue: 0 + boolValue: 0 + floatValue: 5.19999981 + stringValue: + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!114 &1618689136 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 5 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestCall + targetMethodText: 'TestCall (Int32): Void' + methodParameters: + - objValue: + typeAssemblyname: System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.Int32 + intValue: 10 + boolValue: 0 + floatValue: 0 + stringValue: + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!114 &1618689137 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 6 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestCall + targetMethodText: 'TestCall (Boolean): Void' + methodParameters: + - objValue: + typeAssemblyname: System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.Boolean + intValue: 0 + boolValue: 1 + floatValue: 0 + stringValue: + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!114 &1618689138 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5d02d9822eec54c98afe95bb497211b3, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: BoolVar + value: 0 +--- !u!114 &1618689139 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 1 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestCall + targetMethodText: 'TestCall (): Void' + methodParameters: [] + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!114 &1618689140 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea6e8f632db87477eb750446b28d73a3, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 15 + errorMessage: + indentLevel: 0 + commenterName: + commentText: Both these invoke commands use a delay before executing +--- !u!114 &1618689141 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4580f28dd8581476b810b38eea2f1316, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: StringVar + value: +--- !u!114 &1618689142 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 8 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestReturnString + targetMethodText: 'TestReturnString (): String' + methodParameters: [] + saveReturnValue: 1 + returnValueVariableKey: StringVar + returnValueType: System.String + showInherited: 0 + callMode: 0 +--- !u!114 &1618689143 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 705fa1ac97df74e3a84ff952ffd923f1, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: FloatVar + value: 0 +--- !u!114 &1618689144 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: afb91b566ceda411bad1e9d3c3243ecc, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: IntVar + value: 0 +--- !u!114 &1618689145 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 9 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestReturnFloat + targetMethodText: 'TestReturnFloat (): Single' + methodParameters: [] + saveReturnValue: 1 + returnValueVariableKey: FloatVar + returnValueType: System.Single + showInherited: 0 + callMode: 0 +--- !u!114 &1618689146 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 10 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: TestReturnInteger + targetMethodText: 'TestReturnInteger (): Int32' + methodParameters: [] + saveReturnValue: 1 + returnValueVariableKey: IntVar + returnValueType: System.Int32 + showInherited: 0 + callMode: 0 +--- !u!114 &1618689147 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 239 + y: 68 + width: 156 + height: 40 + itemId: 11 + blockName: Test Delayed Invoke + description: This block gets executed by last command in Test Invoke + eventHandler: {fileID: 0} + commandList: + - {fileID: 1618689140} + - {fileID: 1618689149} + - {fileID: 1618689148} +--- !u!114 &1618689148 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 95d9ff288f3904c05ada7ac9c9a075bb, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 13 + errorMessage: + indentLevel: 0 + delay: 2 + invokeType: 0 + staticEvent: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1960615184} + m_MethodName: CheckTestResult + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + booleanParameter: + booleanRef: {fileID: 0} + booleanVal: 0 + booleanEvent: + m_PersistentCalls: + m_Calls: [] + m_TypeName: Fungus.InvokeEvent+BooleanEvent, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + integerParameter: + integerRef: {fileID: 0} + integerVal: 0 + integerEvent: + m_PersistentCalls: + m_Calls: [] + m_TypeName: Fungus.InvokeEvent+IntegerEvent, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + floatParameter: + floatRef: {fileID: 0} + floatVal: 0 + floatEvent: + m_PersistentCalls: + m_Calls: [] + m_TypeName: Fungus.InvokeEvent+FloatEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + stringParameter: + stringRef: {fileID: 0} + stringVal: + stringEvent: + m_PersistentCalls: + m_Calls: [] + m_TypeName: Fungus.InvokeEvent+StringEvent, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &1618689149 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 12 + errorMessage: + indentLevel: 0 + delay: 1 + targetObject: {fileID: 1960615183} + targetComponentAssemblyName: Fungus.TestInvoke, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: TestInvoke + targetMethod: DelayedInvokeEvent + targetMethodText: 'DelayedInvokeEvent (): Void' + methodParameters: [] + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!114 &1618689150 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1618689128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 688e35811870d403f9e2b1ab2a699d98, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 14 + errorMessage: + indentLevel: 0 + delay: 0 + targetObject: {fileID: 1618689128} + targetComponentAssemblyName: Fungus.Flowchart, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + targetComponentFullname: UnityEngine.Component[] + targetComponentText: Flowchart + targetMethod: ExecuteBlock + targetMethodText: 'ExecuteBlock (String): Void' + methodParameters: + - objValue: + typeAssemblyname: System.String, mscorlib, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + typeFullname: System.String + intValue: 0 + boolValue: 0 + floatValue: 0 + stringValue: Test Delayed Invoke + colorValue: {r: 0, g: 0, b: 0, a: 0} + gameObjectValue: {fileID: 0} + materialValue: {fileID: 0} + objectValue: {fileID: 0} + spriteValue: {fileID: 0} + textureValue: {fileID: 0} + vector2Value: {x: 0, y: 0} + vector3Value: {x: 0, y: 0, z: 0} + variableKey: + saveReturnValue: 0 + returnValueVariableKey: + returnValueType: System.Void + showInherited: 0 + callMode: 0 +--- !u!1 &1960615183 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1960615185} + - 114: {fileID: 1960615184} + m_Layer: 0 + m_Name: TestTarget + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1960615184 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1960615183} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 63b819364b72f4eceae495ec5d3173e2, type: 3} + m_Name: + m_EditorClassIdentifier: + flowchart: {fileID: 1618689129} + passCount: 0 +--- !u!4 &1960615185 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1960615183} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -.137771219, y: -.16843766, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1384749030} + m_RootOrder: 1 diff --git a/Assets/Tests/Scripting/Scripting.unity.meta b/Assets/Tests/Scripting/Scripting.unity.meta new file mode 100644 index 00000000..ebf7346c --- /dev/null +++ b/Assets/Tests/Scripting/Scripting.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a2189f9c94ed041ba883f114bc150965 +timeCreated: 1439306636 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Scripting/TestInvoke.cs b/Assets/Tests/Scripting/TestInvoke.cs new file mode 100644 index 00000000..b06224f3 --- /dev/null +++ b/Assets/Tests/Scripting/TestInvoke.cs @@ -0,0 +1,113 @@ +using UnityEngine; +using System.Collections; + +namespace Fungus +{ + + public class TestInvoke : MonoBehaviour + { + public Flowchart flowchart; + + public int passCount; + + public void TestCall() + { + passCount++; + } + + public void TestCall(bool boolParam) + { + if (boolParam) + { + passCount++; + } + } + + public void TestCall(int intParam) + { + if (intParam == 10) + { + passCount++; + } + } + + public void TestCall(float floatParam) + { + if (floatParam == 5.2f) + { + passCount++; + } + } + + public void TestCall(string stringParam) + { + if (stringParam == "ok") + { + passCount++; + } + } + + public bool TestCall(bool boolParam, int intParam, float floatParam, string stringParam) + { + if (boolParam && intParam == 10 && floatParam == 5.2f && stringParam == "ok") + { + passCount++; + } + + return true; + } + + public int TestReturnInteger() + { + passCount++; + return 5; + } + + public float TestReturnFloat() + { + passCount++; + return 22.1f; + } + + public string TestReturnString() + { + passCount++; + return "a string"; + } + + public void DelayedInvokeEvent() + { + passCount++; + } + + public void CheckTestResult() + { + if (flowchart == null) + { + IntegrationTest.Fail("Flowchart object not selected"); + return; + } + + // Check Fungus variables are populated with expected values + if (flowchart.GetBooleanVariable("BoolVar") != true || + flowchart.GetIntegerVariable("IntVar") != 5 || + flowchart.GetFloatVariable("FloatVar") != 22.1f || + flowchart.GetStringVariable("StringVar") != "a string") + { + IntegrationTest.Fail("Fungus variables do not match expected values"); + return; + } + + // Check the right number of methods were invoked successfully + if (passCount == 10) + { + IntegrationTest.Pass(); + } + else + { + IntegrationTest.Fail("A method did not get invoked or parameter was incorrect"); + } + } + } + +} \ No newline at end of file diff --git a/Assets/Tests/Scripting/TestInvoke.cs.meta b/Assets/Tests/Scripting/TestInvoke.cs.meta new file mode 100644 index 00000000..c156319e --- /dev/null +++ b/Assets/Tests/Scripting/TestInvoke.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 63b819364b72f4eceae495ec5d3173e2 +timeCreated: 1439306669 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: