示例#1
0
 void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard);
         checkValue      = BBParameter.CreateInstance(method.ReturnType, blackboard);
         comparison      = CompareMethod.EqualTo;
     }
 }
示例#2
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Field"))
            {
                System.Action <FieldInfo> FieldSelected = (field) => {
                    targetType = field.DeclaringType;
                    fieldName  = field.Name;
                    checkValue = BBParameter.CreateInstance(field.FieldType, blackboard);
                    comparison = CompareMethod.EqualTo;
                };


                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0))
                    {
                        menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component)))
                {
                    menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), FieldSelected, menu);
                }

                if (NodeCanvas.Editor.NCPrefs.useBrowser)
                {
                    menu.ShowAsBrowser("Select Field", this.GetType());
                }
                else
                {
                    menu.ShowAsContext();
                }
                Event.current.Use();
            }

            if (agentType != null && !string.IsNullOrEmpty(fieldName))
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Field", fieldName);
                GUILayout.EndVertical();

                GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
                comparison  = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
                GUI.enabled = true;
                NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue);
            }
        }
示例#3
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);
            }
        }
示例#4
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Field"))
            {
                System.Action <FieldInfo> FieldSelected = (field) => {
                    targetType = field.DeclaringType;
                    fieldName  = field.Name;
                    setValue   = BBParameter.CreateInstance(field.FieldType, blackboard);
                };

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


            if (agentType != null && !string.IsNullOrEmpty(fieldName))
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", agentType.Name);
                UnityEditor.EditorGUILayout.LabelField("Field", fieldName);
                UnityEditor.EditorGUILayout.LabelField("Field Type", setValue.varType.FriendlyName());
                GUILayout.EndVertical();
                EditorUtils.BBParameterField("Set Value", setValue);
            }
        }
示例#5
0
 ////////////////////////////////////////
 ///////////GUI AND EDITOR STUFF/////////
 ////////////////////////////////////////
 #if UNITY_EDITOR
 protected override void OnTaskInspectorGUI()
 {
     DrawDefaultInspector();
     if (GUILayout.Button("Select Type"))
     {
         EditorUtils.ShowPreferedTypesSelectionMenu(typeof(object), (t) => { newValue = BBParameter.CreateInstance(t, blackboard); });
     }
 }