////////////////////////////////////////
        ///////////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);
            }
        }
Beispiel #2
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);
            }
        }
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Method"))
            {
                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 6, false, true, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, true, menu);
                    if (typeof(UnityEngine.Component).IsAssignableFrom(t))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, true, menu);
                    }
                }
                menu.ShowAsBrowser("Select Method", this.GetType());
                Event.current.Use();
            }

            if (targetMethod != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().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++)
                {
                    NodeCanvas.Editor.BBParameterEditor.ParameterField(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;
                NodeCanvas.Editor.BBParameterEditor.ParameterField("Check Value", checkValue);
            }
        }
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Action Method"))
            {
                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(Status), typeof(object), SetMethod, 1, false, true, menu);
                    }
                    menu.AddSeparator("/");
                }

                foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu);
                    if (typeof(UnityEngine.Component).IsAssignableFrom(t))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu);
                    }
                }
                menu.ShowAsBrowser("Select Action Method", this.GetType());
                Event.current.Use();
            }

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

                if (targetMethod.GetParameters().Length == 1)
                {
                    var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase();
                    NodeCanvas.Editor.BBParameterEditor.ParameterField(paramName, functionWrapper.GetVariables()[1]);
                }
            }
        }
Beispiel #5
0
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Property"))
            {
                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    if (typeof(UnityEngine.Component).IsAssignableFrom(t))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    }
                }
                menu.ShowAsBrowser("Select Property", this.GetType());
                Event.current.Use();
            }


            if (targetMethod != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name);
                UnityEditor.EditorGUILayout.LabelField("Property Type", targetMethod.ReturnType.FriendlyName());
                UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetMethod), UnityEditor.MessageType.None);
                GUILayout.EndVertical();
                NodeCanvas.Editor.BBParameterEditor.ParameterField("Save As", functionWrapper.GetVariables()[0], true);
            }
        }
 BBParameter[] ISubParametersContainer.GetSubParameters()
 {
     return(functionWrapper != null?functionWrapper.GetVariables() : null);
 }