protected override void OnNodeInspectorGUI()
        {
            if (outConnections.Count == 0)
            {
                GUILayout.Label("Make some connections first");
                return;
            }

            var total = GetTotal();

            for (var i = 0; i < childWeights.Count; i++)
            {
                GUILayout.BeginHorizontal();
                childWeights[i] = (BBParameter <float>)EditorUtils.BBParameterField("Weight", childWeights[i]);
                GUILayout.Label(Mathf.Round((childWeights[i].value / total) * 100) + "%", GUILayout.Width(38));
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            failChance = (BBParameter <float>)EditorUtils.BBParameterField("Direct Failure Chance", failChance);
            GUILayout.Label(Mathf.Round((failChance.value / total) * 100) + "%", GUILayout.Width(38));
            GUILayout.EndHorizontal();
        }
Exemple #2
0
        protected override void OnNodeInspectorGUI()
        {
            ShowBaseFSMInspectorGUI();
            EditorUtils.BBParameterField("Behaviour Tree", _nestedBT);

            if (nestedBT == null)
            {
                return;
            }

            executionMode = (BTExecutionMode)EditorGUILayout.EnumPopup("Execution Mode", executionMode);
            if (executionMode == BTExecutionMode.RunForever)
            {
                updateInterval = EditorGUILayout.FloatField("Update Interval", updateInterval);
            }

            var alpha1 = string.IsNullOrEmpty(successEvent)? 0.5f : 1;
            var alpha2 = string.IsNullOrEmpty(failureEvent)? 0.5f : 1;

            GUILayout.BeginVertical("box");
            GUI.color    = new Color(1, 1, 1, alpha1);
            successEvent = EditorGUILayout.TextField("Success Event", successEvent);
            GUI.color    = new Color(1, 1, 1, alpha2);
            failureEvent = EditorGUILayout.TextField("Failure Event", failureEvent);
            GUILayout.EndVertical();
            GUI.color = Color.white;

            nestedBT.name = name;
//			nestedBT.ShowDefinedBBVariablesGUI();
        }
Exemple #3
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Action Method"))
            {
                if (agent != null)
                {
                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(Status), typeof(object), SetMethod, 1, false, true);
                }
                else
                {
                    var menu = new UnityEditor.GenericMenu();
                    foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu);
                    }
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }

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

                if (targetMethod.GetParameters().Length == 1)
                {
                    var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase();
                    EditorUtils.BBParameterField(paramName, parameters[0]);
                }
            }
        }
        protected override void OnNodeInspectorGUI()
        {
            EditorUtils.BBParameterField("Nested FSM", _nestedFSM);

            if (nestedFSM == null)
            {
                return;
            }

            successState = EditorUtils.StringPopup("Success State", successState, nestedFSM.GetStateNames().ToList(), false, true);
            failureState = EditorUtils.StringPopup("Failure State", failureState, nestedFSM.GetStateNames().ToList(), false, true);

            var defParams = nestedFSM.GetDefinedParameters();

            if (defParams.Length != 0)
            {
                EditorUtils.TitledSeparator("Defined SubFSM Parameters");
                GUI.color = Color.yellow;
                UnityEditor.EditorGUILayout.LabelField("Name", "Type");
                GUI.color = Color.white;
                var added = new List <string>();
                foreach (var bbVar in defParams)
                {
                    if (!added.Contains(bbVar.name))
                    {
                        UnityEditor.EditorGUILayout.LabelField(bbVar.name, bbVar.varType.FriendlyName());
                        added.Add(bbVar.name);
                    }
                }
                if (GUILayout.Button("Check/Create Blackboard Variables"))
                {
                    nestedFSM.CreateDefinedParameterVariables(graphBlackboard);
                }
            }
        }
 protected override void OnNodeInspectorGUI()
 {
     for (var i = 0; i < priorities.Count; i++)
     {
         priorities[i] = (BBParameter <float>)EditorUtils.BBParameterField("Priority Weight", priorities[i]);
     }
 }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Property"))
            {
                System.Action <MethodInfo> MethodSelected = (method) => {
                    this.method = new SerializedMethodInfo(method);
                    this.parameter.SetType(method.GetParameters()[0].ParameterType);
                };

                if (agent != null)
                {
                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(void), typeof(object), MethodSelected, 1, true, false);
                }
                else
                {
                    var menu = new UnityEditor.GenericMenu();
                    foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(t, typeof(void), typeof(object), MethodSelected, 1, true, false, 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("Set Type", parameter.varType.FriendlyName());
                GUILayout.EndVertical();
                EditorUtils.BBParameterField("Set Value", parameter);
            }
        }
Exemple #7
0
        protected override void OnNodeInspectorGUI()
        {
            EditorUtils.BBParameterField("Behaviour SubTree", _subTree);

            if (subTree == this.graph)
            {
                Debug.LogWarning("You can't have a Graph nested to iteself! Please select another");
                subTree = null;
            }

            if (subTree != null)
            {
                var defParams = subTree.GetDefinedParameters();
                if (defParams.Length != 0)
                {
                    EditorUtils.TitledSeparator("Defined SubTree Parameters");
                    GUI.color = Color.yellow;
                    UnityEditor.EditorGUILayout.LabelField("Name", "Type");
                    GUI.color = Color.white;
                    var added = new List <string>();
                    foreach (var bbVar in defParams)
                    {
                        if (!added.Contains(bbVar.name))
                        {
                            UnityEditor.EditorGUILayout.LabelField(bbVar.name, bbVar.varType.FriendlyName());
                            added.Add(bbVar.name);
                        }
                    }
                    if (GUILayout.Button("Check/Create Blackboard Variables"))
                    {
                        subTree.CreateDefinedParameterVariables(graphBlackboard);
                    }
                }
            }
        }
Exemple #8
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #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 == 0))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(comp.GetType(), typeof(void), typeof(object), SetMethod, 1, true, false, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                {
                    menu = EditorUtils.GetMethodSelectionMenu(t, typeof(void), typeof(object), SetMethod, 1, true, false, 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("Set Type", functionWrapper.GetVariables()[0].varType.FriendlyName());
                GUILayout.EndVertical();
                EditorUtils.BBParameterField("Set Value", functionWrapper.GetVariables()[0]);
            }
        }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #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 == 0))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component)))
                {
                    menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 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);
                GUILayout.EndVertical();

                GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
                comparison  = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
                GUI.enabled = true;
                EditorUtils.BBParameterField("Value", checkValue);
            }
        }
        ////////////////////////////////////////
        ///////////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);
            }
        }
Exemple #11
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 = ReflectedWrapper.Create(method, blackboard);
                };

                if (agent != null)
                {
                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, false);
                }
                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, false, menu);
                    }
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }


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

                if (targetMethod.ReturnType == typeof(IEnumerator))
                {
                    GUILayout.Label("<b>This will execute as a Coroutine</b>");
                }

                GUILayout.EndVertical();

                var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray();
                var variables  = functionWrapper.GetVariables();
                if (targetMethod.ReturnType == typeof(void))
                {
                    for (var i = 0; i < paramNames.Length; i++)
                    {
                        EditorUtils.BBParameterField(paramNames[i], variables[i]);
                    }
                }
                else
                {
                    for (var i = 0; i < paramNames.Length; i++)
                    {
                        EditorUtils.BBParameterField(paramNames[i], variables[i + 1]);
                    }
                    EditorUtils.BBParameterField("Save Return Value", variables[0], true);
                }
            }
        }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #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 != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 10, false, false, menu);
                    }
                    menu.AddSeparator("/");
                }

                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component)))
                {
                    menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, false, menu);
                }
                if (NodeCanvas.Editor.NCPrefs.useBrowser)
                {
                    menu.ShowAsBrowser("Select Method", this.GetType());
                }
                else
                {
                    menu.ShowAsContext();
                }
                Event.current.Use();
            }


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

                if (targetMethod.ReturnType == typeof(IEnumerator))
                {
                    GUILayout.Label("<b>This will execute as a Coroutine</b>");
                }

                GUILayout.EndVertical();


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

                if (targetMethod.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator))
                {
                    EditorUtils.BBParameterField("Save Return Value", returnValue, true);
                }
            }
        }
Exemple #13
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            languageSource = EditorUtils.BBParameterField("Language Source", languageSource) as BBParameter <LanguageSource>;

            EditTermSelection();
            //statement.text = UnityEditor.EditorGUILayout.TextArea(statement.text, (GUIStyle)"textField", GUILayout.Height(100));
            statement.audio = (AudioClip)UnityEditor.EditorGUILayout.ObjectField("Audio Clip", statement.audio, typeof(AudioClip), false);
            statement.meta  = UnityEditor.EditorGUILayout.TextField("Meta", statement.meta);
        }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Method")){

                System.Action<MethodInfo> MethodSelected = (method) => {
                    this.method = new SerializedMethodInfo(method);
                    this.parameters.Clear();
                    foreach(var p in method.GetParameters()){
                        var newParam = new BBObjectParameter{bb = blackboard};
                        newParam.SetType(p.ParameterType);
                        if (p.IsOptional){
                            newParam.value = p.DefaultValue;
                        }
                        parameters.Add(newParam);
                    }

                    if (method.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){
                        this.returnValue = new BBObjectParameter{bb = blackboard};
                        this.returnValue.SetType(method.ReturnType);
                    }
                };

                if (agent != null){

                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, false);

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

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

                if (targetMethod.ReturnType == typeof(IEnumerator))
                    GUILayout.Label("<b>This will execute as a Coroutine</b>");

                GUILayout.EndVertical();

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

                if (targetMethod.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){
                    EditorUtils.BBParameterField("Save Return Value", returnValue, true);
                }
            }
        }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Static Method"))
            {
                UnityEditor.GenericMenu.MenuFunction2 MethodSelected = (m) => {
                    SetMethod((MethodInfo)m);
                };

                var menu = new UnityEditor.GenericMenu();
                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    foreach (var m in t.GetMethods(BindingFlags.Static | BindingFlags.Public).OrderBy(m => !m.IsSpecialName))
                    {
                        if (m.IsGenericMethod)
                        {
                            continue;
                        }

                        menu.AddItem(new GUIContent(t.FriendlyName() + "/" + m.SignatureName()), false, MethodSelected, m);
                    }
                }
                if (NodeCanvas.Editor.NCPrefs.useBrowser)
                {
                    menu.ShowAsBrowser("Select Static Method", this.GetType());
                }
                else
                {
                    menu.ShowAsContext();
                }
                Event.current.Use();
            }


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

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

                if (targetMethod.ReturnType != typeof(void))
                {
                    EditorUtils.BBParameterField("Save Return Value", returnValue, true);
                }
            }
        }
        protected override void OnNodeInspectorGUI()
        {
            ShowBaseFSMInspectorGUI();
            EditorUtils.BBParameterField("Behaviour Tree", _nestedBT);

            if (nestedBT == null)
            {
                return;
            }

            executionMode = (BTExecutionMode)EditorGUILayout.EnumPopup("Execution Mode", executionMode);
            if (executionMode == BTExecutionMode.RunForever)
            {
                updateInterval = EditorGUILayout.FloatField("Update Interval", updateInterval);
            }

            var alpha1 = string.IsNullOrEmpty(successEvent)? 0.5f : 1;
            var alpha2 = string.IsNullOrEmpty(failureEvent)? 0.5f : 1;

            GUILayout.BeginVertical("box");
            GUI.color    = new Color(1, 1, 1, alpha1);
            successEvent = EditorGUILayout.TextField("Success Event", successEvent);
            GUI.color    = new Color(1, 1, 1, alpha2);
            failureEvent = EditorGUILayout.TextField("Failure Event", failureEvent);
            GUILayout.EndVertical();
            GUI.color = Color.white;

            nestedBT.name = name;


            var defParams = nestedBT.GetDefinedParameters();

            if (defParams.Length != 0)
            {
                EditorUtils.TitledSeparator("Defined Nested BT Parameters");
                GUI.color = Color.yellow;
                EditorGUILayout.LabelField("Name", "Type");
                GUI.color = Color.white;
                var added = new List <string>();
                foreach (var bbVar in defParams)
                {
                    if (!added.Contains(bbVar.name))
                    {
                        EditorGUILayout.LabelField(bbVar.name, bbVar.varType.FriendlyName());
                        added.Add(bbVar.name);
                    }
                }
                if (GUILayout.Button("Check/Create Blackboard Variables"))
                {
                    nestedBT.CreateDefinedParameterVariables(graphBlackboard);
                }
            }
        }
Exemple #17
0
        protected override void OnNodeInspectorGUI()
        {
            repeaterMode = (RepeaterMode)UnityEditor.EditorGUILayout.EnumPopup("Repeat Type", repeaterMode);

            if (repeaterMode == RepeaterMode.RepeatTimes)
            {
                repeatTimes = (BBParameter <int>)EditorUtils.BBParameterField("Repeat Times", repeatTimes);
            }
            else if (repeaterMode == RepeaterMode.RepeatUntil)
            {
                repeatUntilStatus = (RepeatUntilStatus)UnityEditor.EditorGUILayout.EnumPopup("Repeat Until", repeatUntilStatus);
            }
        }
Exemple #18
0
        protected override void OnNodeInspectorGUI()
        {
            EditorUtils.BBParameterField("Nested FSM", _nestedFSM);

            if (nestedFSM == null)
            {
                return;
            }

            successState = EditorUtils.StringPopup("Success State", successState, nestedFSM.GetStateNames().ToList(), false, true);
            failureState = EditorUtils.StringPopup("Failure State", failureState, nestedFSM.GetStateNames().ToList(), false, true);
//		    nestedFSM.ShowDefinedBBVariablesGUI();
        }
Exemple #19
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.GetFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                {
                    menu = EditorUtils.GetFieldSelectionMenu(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;
                EditorUtils.BBParameterField("Value", checkValue);
            }
        }
Exemple #20
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #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.GetMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 6, false, true, menu);
                    }
                    menu.AddSeparator("/");
                }

                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component)))
                {
                    menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, true, menu);
                }
                if (NodeCanvas.Editor.NCPrefs.useBrowser)
                {
                    menu.ShowAsBrowser("Select Method", this.GetType());
                }
                else
                {
                    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);
            }
        }
Exemple #21
0
        protected override void OnNodeInspectorGUI()
        {
            EditorUtils.BBParameterField("Behaviour SubTree", _subTree);

            if (subTree == this.graph)
            {
                Debug.LogWarning("You can't have a Graph nested to iteself! Please select another");
                subTree = null;
            }

            if (subTree != null)
            {
//		        subTree.ShowDefinedBBVariablesGUI();
            }
        }
Exemple #22
0
        protected override void OnNodeInspectorGUI()
        {
            base.OnNodeInspectorGUI();
            EditorUtils.BBParameterField("Sub Dialogue Tree", _subTree);
            if (subTree == this.DLGTree)
            {
                Debug.LogWarning("Nested DialogueTree can't be itself! Please select another");
                subTree = null;
            }

            if (subTree != null)
            {
                ShowActorParametersMapping();
                ShowVariablesMapping();
            }
        }
Exemple #23
0
        protected override void OnNodeInspectorGUI()
        {
            filterMode = (FilterMode)UnityEditor.EditorGUILayout.EnumPopup("Mode", filterMode);

            if (filterMode == FilterMode.CoolDown)
            {
                coolDownTime = (BBParameter <float>)EditorUtils.BBParameterField("CoolDown Time", coolDownTime);
            }
            else
            if (filterMode == FilterMode.LimitNumberOfTimes)
            {
                maxCount = (BBParameter <int>)EditorUtils.BBParameterField("Max Times", maxCount);
            }

            inactiveWhenLimited = UnityEditor.EditorGUILayout.Toggle("Inactive When Limited", inactiveWhenLimited);
        }
Exemple #24
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Action Method"))
            {
                System.Action <MethodInfo> MethodSelected = (method) => {
                    this.method = new SerializedMethodInfo(method);
                    this.parameters.Clear();
                    foreach (var p in method.GetParameters())
                    {
                        var newParam = new BBObjectParameter {
                            bb = blackboard
                        };
                        newParam.SetType(p.ParameterType);
                        parameters.Add(newParam);
                    }
                };

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

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

                if (targetMethod.GetParameters().Length == 1)
                {
                    var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase();
                    EditorUtils.BBParameterField(paramName, parameters[0]);
                }
            }
        }
Exemple #25
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            languageSource = EditorUtils.BBParameterField("Language Source", languageSource) as BBParameter <LanguageSource>;

            selectionMode = EditorUtils.BBParameterField("Selection Mode", selectionMode) as BBParameter <bool>;

            if (selectionMode.value)
            {
                EditTermSelection();
            }
            else
            {
                term = EditorUtils.BBParameterField("Term", term) as BBParameter <string>;
            }

            translation = EditorUtils.BBParameterField("Translation", translation) as BBParameter <string>;
        }
Exemple #26
0
        protected override void OnNodeInspectorGUI()
        {
            ShowBaseFSMInspectorGUI();
            EditorUtils.BBParameterField("FSM", _nestedFSM);

            if (nestedFSM == this.FSM)
            {
                Debug.LogWarning("Nested FSM can't be itself!");
                nestedFSM = null;
            }

            if (nestedFSM != null)
            {
                nestedFSM.name = this.name;
//				nestedFSM.ShowDefinedBBVariablesGUI();
            }
        }
Exemple #27
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;
                    saveAs.SetType(field.FieldType);
                };

                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component)))
                {
                    menu = EditorUtils.GetFieldSelectionMenu(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.Name);
                UnityEditor.EditorGUILayout.LabelField("Field", fieldName);
                UnityEditor.EditorGUILayout.LabelField("Field Type", saveAs.varType.FriendlyName());
                GUILayout.EndVertical();
                EditorUtils.BBParameterField("Save As", saveAs, true);
            }
        }
Exemple #28
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);
            }
        }
Exemple #29
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            localizeObject = EditorUtils.BBParameterField("Localize Object", localizeObject) as BBParameter <Localize>;

            var terms = (!localizeObject.isNull && localizeObject.value.Source != null)
                ? localizeObject.value.Source.GetTermsList()
                : LocalizationManager.GetTermsList();

            terms.Sort(System.StringComparer.OrdinalIgnoreCase);
            terms.Add("");
            terms.Add("<inferred from text>");
            terms.Add("<none>");
            var aTerms = terms.ToArray();

            DoTermPopup("Primary Term", primaryTerm, aTerms);
            DoTermPopup("Secondary Term", secondaryTerm, aTerms);
        }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Event"))
            {
                Action <EventInfo> Selected = (e) => {
                    targetType = e.DeclaringType;
                    eventName  = e.Name;
                };


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

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

            if (targetType != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Selected Type", agentType.FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Selected Event", eventName);
                GUILayout.EndVertical();

                EditorUtils.BBParameterField("Check Value", checkValue);
            }
        }