void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard);
     }
 }
Example #2
0
 public override void OnValidate(ITaskSystem ownerSystem)
 {
     if (functionWrapper != null && functionWrapper.HasChanged())
     {
         functionWrapper = ReflectedFunctionWrapper.Create(functionWrapper.GetMethod(), blackboard);
     }
 }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Property"))
            {
                System.Action <MethodInfo> MethodSelected = (method) => {
                    functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard);
                };

                if (agent != null)
                {
                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 0, true, true);
                }
                else
                {
                    var menu = new UnityEditor.GenericMenu();
                    foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 0, true, true, menu);
                    }
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }


            if (targetMethod != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name);
                UnityEditor.EditorGUILayout.LabelField("Property Type", targetMethod.ReturnType.FriendlyName());
                GUILayout.EndVertical();
                EditorUtils.BBParameterField("Save As", functionWrapper.GetVariables()[0], true);
            }
        }
Example #4
0
 void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard);
         checkValue      = BBParameter.CreateInstance(method.ReturnType, blackboard);
         comparison      = CompareMethod.EqualTo;
     }
 }
Example #5
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Method"))
            {
                System.Action <MethodInfo> MethodSelected = (method) => {
                    functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard);
                    checkValue      = BBParameter.CreateInstance(method.ReturnType, blackboard);
                    comparison      = CompareMethod.EqualTo;
                };

                if (agent != null)
                {
                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, true);
                }
                else
                {
                    var menu = new UnityEditor.GenericMenu();
                    foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component)))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 3, false, true, menu);
                    }
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }

            if (targetMethod != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name);
                GUILayout.EndVertical();

                var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray();
                var variables  = functionWrapper.GetVariables();
                for (var i = 0; i < paramNames.Length; i++)
                {
                    EditorUtils.BBParameterField(paramNames[i], variables[i + 1]);
                }

                GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
                comparison  = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
                GUI.enabled = true;
                EditorUtils.BBParameterField("Check Value", checkValue);
            }
        }