コード例 #1
0
        private void DrawInEditMode()
        {
            GUILayout.BeginHorizontal();

            //Edit button, swap between edit and show state
            if (GUILayout.Button("-", GUILayout.Width(20), GUILayout.Height(20)) || Application.isPlaying)
            {
                //Change state
                _UI_mode = EditorUIMode.SET_STATE;
                //Set input focus to null
                GUI.FocusControl("null");
                //Check name change
                if (string.Compare(new_name, _target_variable.name) != 0)
                {
                    //Repeated name case
                    if (_target_blackboard.variables.ContainsKey(new_name))
                    {
                        Debug.LogWarning("The name '" + new_name + "' already exists!");
                    }
                    //New name case
                    else
                    {
                        //Change key in the dictionary, the variable is now stored with the new key
                        _target_blackboard.variables.RenameKey(_target_variable.name, new_name);
                        //Change variable name
                        _target_variable.name = new_name;
                    }
                }
                //Free dropdown slots
                ProTools.FreeDropdownSlot(_variable_dropdown_data.dropdown_slot);
                ProTools.FreeDropdownSlot(_method_dropdown_data.dropdown_slot);

                return;
            }

            //Show variable type
            GUILayout.Label(_target_variable.type.ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(60.0f));

            //Edit variable name
            new_name = EditorGUILayout.TextField(new_name, GUILayout.MaxWidth(80.0f));

            //Show variable value
            //Non binded variable case
            if (!_target_variable.is_field_binded && !_target_variable.is_method_binded)
            {
                //Get variable value
                object value = _target_variable.object_value;
                //Generate UI field from type
                ProTools.ValueFieldByVariableType(_target_variable.type, ref value);
                //If value is different we update the variable value
                if (value.Equals(_target_variable.object_value) == false)
                {
                    _target_variable.value = value;
                }
            }

            ShowBindOptions();

            GUILayout.EndHorizontal();
        }
コード例 #2
0
        //Constructors ================
        public ScriptCreationMenu_GS(ScriptCreationType new_creation_type, int node_index = 0)
        {
            //Set script creation type
            _script_creation_type = new_creation_type;
            //Set action node case index
            _node_index = node_index;

            //Check what
            switch (_script_creation_type)
            {
            case ScriptCreationType.ScriptC_action:
            {
                _window_title = "Action";
            }
            break;

            case ScriptCreationType.ScriptC_behaviour:
            {
                _window_title = "Behaviour";
            }
            break;
            }

            //Get dropdown slot for folder selection
            _folder_dropdown_slot = ProTools.GetDropdownSlot();
        }
コード例 #3
0
 public override void OnClose()
 {
     //Free dropdown slots
     ProTools.FreeDropdownSlot(_A_key_dropdown_slot);
     ProTools.FreeDropdownSlot(_operator_dropdown_slot);
     ProTools.FreeDropdownSlot(_B_key_dropdown_slot);
 }
コード例 #4
0
 //Constructors ================
 public BehaviourSelectMenu_GS(Agent_GS new_target_agent)
 {
     //Set the target agent
     _target_agent = new_target_agent;
     //Get dropdown slot for behaviour select
     _behaviour_dropdown_slot = ProTools.GetDropdownSlot();
 }
コード例 #5
0
 //Contructors =================
 public VariableSelectMenu_GS(bool global = false)
 {
     //Set global
     _global_blackboard = global;
     //Initialize the variable dropdown data
     _variable_dropdown_data = new ProTools.DropDownData_GS();
     //Get dropdown slots
     _variable_dropdown_data.dropdown_slot = ProTools.GetDropdownSlot();
 }
コード例 #6
0
 //Constructors ================
 public ActionSelectMenu_GS(ActionNode_GS_Editor new_target_action_node_editor)
 {
     if (new_target_action_node_editor != null)
     {
         //Focus the action node
         _target_action_node_editor = new_target_action_node_editor;
         _target_action_node        = _target_action_node_editor.target_action_node;
     }
     //Get dropdown slot for action select
     _action_dropdown_slot = ProTools.GetDropdownSlot();
 }
コード例 #7
0
        private void Update()
        {
            //Try to get the script in the action scripts resources tool
            UnityEngine.Object script = null;
            switch (_script_creation_type)
            {
            case ScriptCreationMenu_GS.ScriptCreationType.ScriptC_action:
            {
                if (ResourcesTool.action_scripts.TryGetValue(_script_full_path.Substring(7), out script))
                {
                    //Allocate a class with the same type of script value
                    Planning.Action_GS _new_script = ProTools.AllocateClass <Planning.Action_GS>(script);
                    //Set new script name
                    _new_script.name = _script_full_path.PathToName();
                    //Place the new action in the selected action node
                    NodeEditor_GS.Instance.selected_agent.action_nodes[_node_index].action = _new_script;
                    //Set action node editor action editor
                    NodeEditor_GS.Instance.action_node_editors[_node_index].action_editor = new Action_GS_Editor(NodeEditor_GS.Instance.action_node_editors[_node_index]);
                    //This dummy gameobject job is done, we can delete it
                    DestroyImmediate(gameObject);
                    return;
                }
            }
            break;

            case ScriptCreationMenu_GS.ScriptCreationType.ScriptC_behaviour:
            {
                if (ResourcesTool.agent_behaviour_scripts.TryGetValue(_script_full_path.Substring(7), out script))
                {
                    //Allocate a class with the same type of script value
                    AI.AgentBehaviour_GS _new_script = ProTools.AllocateClass <AI.AgentBehaviour_GS>(script);
                    //Set new script name
                    _new_script.name = _script_full_path.PathToName();
                    //Place the new action in the selected action node
                    NodeEditor_GS.Instance.selected_agent.behaviour = _new_script;
                    //Update node planning canvas
                    NodePlanning_GS.Instance.Repaint();
                    //This dummy gameobject job is done, we can delete it
                    DestroyImmediate(gameObject);
                }
            }
            break;
            }
            //Count test
            try_count += 1;
            if (try_count > ProTools.TRIES_LIMIT)
            {
                //Warning message display
                Debug.LogWarning("New script: " + _script_full_path.PathToName() + " target not found!");
                //Destroy gameobject
                DestroyImmediate(gameObject);
            }
        }
コード例 #8
0
        private bool _has_method_parameters = false; //If the variable is binded with a method without input parameters, the input selection menu is blocked

        //Constructors ====================
        public Variable_GS_Editor(Variable_GS new_variable, Blackboard_GS new_bb)
        {
            //Set target variable
            _target_variable = new_variable;
            //Set target bb
            _target_blackboard = new_bb;
            //Initialize dropdowns data
            _variable_dropdown_data = new ProTools.DropDownData_GS();
            _method_dropdown_data   = new ProTools.DropDownData_GS();
            //Check for binded method parameters
            if (string.IsNullOrEmpty(_target_variable.binded_method_path) == false)
            {
                _has_method_parameters = ProTools.FindMethodFromPath(_target_variable.binded_method_path, _target_variable.system_type, _target_blackboard.target_agent.gameObject).Key.GetParameters().Length > 0;
            }
        }
コード例 #9
0
        private int _B_key_dropdown_slot    = -1;                                        //B key dropdown slot

        //Contructors =================
        public PropertySelectMenu_GS(ActionNode_GS_Editor new_target_action_node_editor, PropertyUIMode new_property_UI_mode)
        {
            //Set property UI mode
            _property_UI_mode = new_property_UI_mode;
            //Set menu title
            if (_property_UI_mode == PropertyUIMode.IS_CONDITION)
            {
                //Condition title case
                _menu_title = "Condition Select";
            }
            else if (_property_UI_mode == PropertyUIMode.IS_EFFECT)
            {
                //Effect title case
                _menu_title = "Effect Select";
            }
            //Set the action node is this menu working with
            _target_action_node_editor = new_target_action_node_editor;

            //Get local blackboard variables keys
            string[] local_keys = NodeEditor_GS.Instance.selected_agent.blackboard.GetKeys();

            //Get global blackboard variables keys
            string[] global_keys = GlobalBlackboard_GS.blackboard.GetKeys();

            //Allocate string array to store all the keys
            _A_variable_keys          = new string[local_keys.Length + global_keys.Length];
            _original_A_variable_keys = new string[local_keys.Length + global_keys.Length];

            //Add the local keys with a prefix for the dropdown
            for (int k = 0; k < local_keys.Length; k++)
            {
                _A_variable_keys[k]          = "Local/" + local_keys[k];
                _original_A_variable_keys[k] = local_keys[k];
            }

            //Add the global keys with a prefix for the dropdown
            for (int k = local_keys.Length, i = 0; k < _A_variable_keys.Length; k++, i++)
            {
                _A_variable_keys[k]          = "Global/" + global_keys[i];
                _original_A_variable_keys[k] = global_keys[i];
            }

            //Get dropdown slots
            _A_key_dropdown_slot    = ProTools.GetDropdownSlot();
            _operator_dropdown_slot = ProTools.GetDropdownSlot();
            _B_key_dropdown_slot    = ProTools.GetDropdownSlot();
        }
コード例 #10
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            editorWindow.minSize = new Vector2(200.0f, 120.0f);
            editorWindow.maxSize = new Vector2(200.0f, 120.0f);

            GUILayout.BeginVertical();

            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label(_window_title + "Script Creation", UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Folder area
            GUILayout.BeginHorizontal();
            //Folder label
            GUILayout.Label("Folder:", GUILayout.MaxWidth(50.0f));
            //Folder dropdown button
            ProTools.GenerateButtonDropdownMenu(ref _folder_selected_index, ResourcesTool.assets_folders, _folder_selected_index == -1 ? "Not Set" : ResourcesTool.assets_folders[_folder_selected_index].FolderToName(), false, 150.0f, _folder_dropdown_slot);
            GUILayout.EndHorizontal();

            //Name Text field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name:", GUILayout.MaxWidth(50.0f));
            _new_script_name = EditorGUILayout.TextField("", _new_script_name, GUILayout.MaxWidth(140.0f));
            GUILayout.EndHorizontal();

            //Flexible space separation
            GUILayout.FlexibleSpace();

            //Create/Cancel buttons
            GUILayout.BeginHorizontal();
            //Create
            if (GUILayout.Button("Create", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(30), GUILayout.ExpandWidth(true)) &&
                _folder_selected_index != -1 && //Path is set
                !string.IsNullOrEmpty(_new_script_name))    //Name is set
            {
                //Adapt class name (class name can't have spaces)
                _new_script_name = _new_script_name.Replace(' ', '_');
                //Generate new script path
                _new_script_full_path = ResourcesTool.assets_folders[_folder_selected_index] + '/' + _new_script_name + ".cs";
                //Check if the file exists
                if (File.Exists(_new_script_full_path) == true)
                {
                    //Script already exists case
                    Debug.LogWarning("Already exists a script named: " + _new_script_name + "in the folder: " + ResourcesTool.assets_folders[_folder_selected_index]);
                }
                else
                {
                    //New script case
                    using (StreamWriter new_script = new StreamWriter(_new_script_full_path))
                    {
                        switch (_script_creation_type)
                        {
                        case ScriptCreationType.ScriptC_action:
                        {
                            //Set new action script code
                            new_script.WriteLine("using UnityEngine;");
                            new_script.WriteLine("using GOAP_S.Planning;");
                            new_script.WriteLine("public class " + _new_script_name + " : Action_GS");
                            new_script.WriteLine("{");
                            //TODO
                            new_script.WriteLine("}");
                        }
                        break;

                        case ScriptCreationType.ScriptC_behaviour:
                        {
                            //Set new behaiour script code
                            new_script.WriteLine("using UnityEngine;");
                            new_script.WriteLine("using GOAP_S.AI;");
                            new_script.WriteLine("public class " + _new_script_name + " : AgentBehaviour_GS");
                            new_script.WriteLine("{");
                            //TODO
                            new_script.WriteLine("}");
                        }
                        break;
                        }
                    }

                    //Refresh assets
                    AssetDatabase.Refresh();
                    //Load asset and save it in the generated script static object to use it in future actions
                    GameObject temp_compilation_obj = new GameObject();
                    temp_compilation_obj.transform.parent = Selection.activeGameObject.transform;

                    ScriptCreationSetter_GS temp_comp = temp_compilation_obj.AddComponent <ScriptCreationSetter_GS>();
                    temp_comp._script_full_path     = _new_script_full_path;
                    temp_comp._script_creation_type = _script_creation_type;
                    temp_comp._node_index           = _node_index;
                }

                //Close popup window
                editorWindow.Close();
            }
            //Cancel
            if (GUILayout.Button("Cancel", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(30), GUILayout.ExpandWidth(true)))
            {
                //First check if there's a method to call
                if (on_script_creation_cancel_delegate != null)
                {
                    //Call the script creation cancel delegate
                    on_script_creation_cancel_delegate();
                    //Reset on script creation cancel delegate
                    on_script_creation_cancel_delegate = null;
                }

                //Close popup window
                editorWindow.Close();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
コード例 #11
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            editorWindow.maxSize = new Vector2(200.0f, 170.0f);
            editorWindow.minSize = new Vector2(200.0f, 170.0f);

            GUILayout.BeginVertical();

            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label(_menu_title, UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);


            //Variable select
            GUILayout.BeginHorizontal();
            GUILayout.Label("Variable:", GUILayout.MaxWidth(60.0f));
            //Generate dropdown with the variables in the target blackboard
            ProTools.GenerateButtonDropdownMenu(ref _selected_A_key_index, _A_variable_keys, "Not Set", true, 120.0f, _A_key_dropdown_slot);

            //Check variable selection change
            if (prev_selected_variable_index != _selected_A_key_index)
            {
                if (_selected_A_key_index != -1)
                {
                    //If the selected index is valid we get the variable type
                    if (_selected_A_key_index + 1 > NodeEditor_GS.Instance.selected_agent.blackboard.variables.Count)
                    {
                        //Global variable case
                        _selected_variable_type = GlobalBlackboard_GS.blackboard.variables[_original_A_variable_keys[_selected_A_key_index]].type;
                    }
                    else
                    {
                        //Local variable case
                        _selected_variable_type = NodeEditor_GS.Instance.selected_agent.blackboard.variables[_original_A_variable_keys[_selected_A_key_index]].type;
                    }

                    //Then we can allocate the property value with the variable type
                    ProTools.AllocateFromVariableType(_selected_variable_type, ref _selected_value);
                    //Get valid operators
                    //Need to check if si a condition or an effect
                    if (_property_UI_mode == PropertyUIMode.IS_CONDITION)
                    {
                        //Condition passive operators case
                        _valid_operators = _selected_variable_type.GetValidPassiveOperatorTypes();
                    }
                    else if (_property_UI_mode == PropertyUIMode.IS_EFFECT)
                    {
                        //Effect active operators case
                        _valid_operators = _selected_variable_type.GetValidActiveOperatorTypes();
                    }
                    //Reset operator selected
                    _selected_operator_index = -1;

                    //Get local blackboard variables keys with the same type
                    string[] local_keys = NodeEditor_GS.Instance.selected_agent.blackboard.GetKeysByVariableType(_selected_variable_type);
                    //Get global blackboard variables keys with the same type
                    string[] global_keys = GlobalBlackboard_GS.blackboard.GetKeysByVariableType(_selected_variable_type);
                    //Allocate string array to store all the keys
                    _B_variable_keys          = new string[local_keys.Length + global_keys.Length];
                    _original_B_variable_keys = new string[local_keys.Length + global_keys.Length];
                    //Add the local keys with a prefix for the dropdown
                    for (int k = 0; k < local_keys.Length; k++)
                    {
                        _B_variable_keys[k]          = "Local/" + local_keys[k];
                        _original_B_variable_keys[k] = local_keys[k];
                    }
                    //Add the global keys with a prefix for the dropdown
                    for (int k = local_keys.Length, i = 0; k < _B_variable_keys.Length; k++, i++)
                    {
                        _B_variable_keys[k]          = "Global/" + global_keys[i];
                        _original_B_variable_keys[k] = global_keys[i];
                    }

                    //Reset B key selected
                    _selected_B_key_index = -1;
                }
                else
                {
                    //In non valid index case we reset the property data
                    _selected_variable_type  = VariableType._undefined_var_type;
                    _selected_value          = null;
                    _valid_operators         = null;
                    _selected_operator_index = -1;
                }
                prev_selected_variable_index = _selected_A_key_index;
            }
            GUILayout.EndHorizontal();

            //Operator select
            GUILayout.BeginHorizontal();
            if (_valid_operators != null)
            {
                GUILayout.Label("Operator:", GUILayout.MaxWidth(60.0f));
                //Generate enumerator popup with the operator type
                ProTools.GenerateButtonDropdownMenu(ref _selected_operator_index, _valid_operators.ToShortStrings(), "Not Set", true, 120.0f, _operator_dropdown_slot);
            }
            GUILayout.EndHorizontal();

            //Value area
            //Target select
            GUILayout.BeginVertical();
            if (_selected_A_key_index != -1)
            {
                if (_value_or_key == 0 || _value_or_key == 1)
                {
                    if (GUILayout.Button("Use Variable", GUILayout.MaxWidth(100.0f)))
                    {
                        _value_or_key = 2;
                    }
                }
                else if (_value_or_key == 2)
                {
                    if (GUILayout.Button("Use Value", GUILayout.MaxWidth(100.0f)))
                    {
                        _value_or_key = 1;
                    }
                }
            }
            //Value select
            GUILayout.BeginHorizontal();
            if (_selected_A_key_index != -1)
            {
                if (_value_or_key == 0 || _value_or_key == 1)
                {
                    GUILayout.Label("Value:", GUILayout.MaxWidth(60.0f));
                }
                else if (_value_or_key == 2)
                {
                    GUILayout.Label("Variable:", GUILayout.MaxWidth(60.0f));
                }

                //Show input field in value case
                if (_value_or_key == 1 || _value_or_key == 0)
                {
                    //Show field on valid index case
                    ProTools.ValueFieldByVariableType(_selected_variable_type, ref _selected_value);
                }
                //Show input field in variable case
                else if (_value_or_key == 2)
                {
                    //Generate enumerator popup with the avaliable B keys
                    ProTools.GenerateButtonDropdownMenu(ref _selected_B_key_index, _B_variable_keys, "Not Set", true, 120.0f, _B_key_dropdown_slot);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            //Separation
            GUILayout.FlexibleSpace();

            //Add/Close buttons
            GUILayout.BeginHorizontal();
            //Add button
            if (GUILayout.Button("Add", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                //First we need to check if all the fields are correctly filled
                if (_selected_A_key_index == -1 || _selected_operator_index == -1 || (_value_or_key == 2 && _selected_B_key_index == -1))
                {
                    Debug.LogWarning("Fields are not filled correctly!");
                }
                //If everithing is correct we generate the condition
                else
                {
                    //First allocate the property class
                    Property_GS new_property = new Property_GS();
                    //Set A key
                    new_property.A_key = _A_variable_keys[_selected_A_key_index];
                    //Set variable type
                    new_property.variable_type = _selected_variable_type;
                    //Set operator type
                    new_property.operator_type = _valid_operators[_selected_operator_index];
                    //Set value or key in property B part
                    if (_value_or_key == 2)
                    {
                        new_property.B_key = _B_variable_keys[_selected_B_key_index];
                        //Set value as B variable
                        string[] B_key_info = new_property.B_key.Split('/');
                        if (string.Compare(B_key_info[0], "Global") == 0)
                        {
                            new_property.value = GlobalBlackboard_GS.blackboard.GetObjectVariable(B_key_info[1]);
                        }
                        else
                        {
                            new_property.value = NodeEditor_GS.Instance.selected_agent.blackboard.GetObjectVariable(B_key_info[1]);
                        }
                    }
                    else
                    {
                        new_property.value = _selected_value;
                    }
                    //Add property to the action node we are working with
                    //Need to check if is a condition or an effect
                    if (_property_UI_mode == PropertyUIMode.IS_CONDITION)
                    {
                        //Add condition case
                        _target_action_node_editor.AddCondition(new_property);
                    }
                    else if (_property_UI_mode == PropertyUIMode.IS_EFFECT)
                    {
                        //Add effect case
                        _target_action_node_editor.AddEffect(new_property);
                    }
                    //Close this menu
                    editorWindow.Close();
                    //Update node editor
                    NodeEditor_GS.Instance.Repaint();
                }
            }
            //Close button
            if (GUILayout.Button("Close", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                editorWindow.Close();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
コード例 #12
0
        //Loop Methods ================
        public void DrawUI(int id)
        {
            //Separaion between title and variables
            GUILayout.BeginVertical();
            GUILayout.Space(15);
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.EndVertical();

            //No behaviour selected case
            if (_target_agent.behaviour == null)
            {
                GUILayout.Label("No Behaviour", UIConfig_GS.center_big_white_style);
                //Behaviour select button
                if (GUILayout.Button(new GUIContent("Set Behaviour", "Choose a behaviour script from the assets"), UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    Vector2 mousePos = Event.current.mousePosition;
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new BehaviourSelectMenu_GS(_target_agent));
                }
            }
            //Behaviour selected case
            else
            {
                //Behaviour name
                GUILayout.BeginHorizontal("HelpBox");
                GUILayout.FlexibleSpace();
                GUILayout.Label(_target_agent.behaviour.name, UIConfig_GS.Instance.node_elements_style, GUILayout.ExpandWidth(true));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                //Behaviour select button
                if (GUILayout.Button(new GUIContent("Change Behaviour", "Choose a behaviour script from the assets"), UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    Vector2 mousePos = Event.current.mousePosition;
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new BehaviourSelectMenu_GS(_target_agent));
                }

                //Behaviour edit button
                if (GUILayout.Button(new GUIContent("Edit Behaviour", "Open the currently selected behaviour script with the code editor"), UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    ProTools.OpenScriptEditor(_target_agent.behaviour.GetType());
                }
            }

            //Separaion between behaviour script and idle action script
            GUILayout.BeginVertical();
            GUILayout.Space(10);
            //Idle action title
            GUILayout.Label(new GUIContent("Idle Action", "Action that will be executed when there is no planning action to execute"), UIConfig_GS.center_big_style);
            //Line separator
            GUILayout.Space(-5);
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.EndVertical();



            //No idle action selected case
            if (_target_agent.idle_action == null)
            {
                GUILayout.Label("No Action", UIConfig_GS.center_big_white_style);
                //Action select dropdown
                if (GUILayout.Button("Set Action", UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    Vector2 mousePos = Event.current.mousePosition;
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new ActionSelectMenu_GS(null));
                }
            }
            //Idle action selected case
            else
            {
                //Action name
                GUILayout.BeginHorizontal("HelpBox");
                GUILayout.FlexibleSpace();
                GUILayout.Label(_target_agent.idle_action.name, UIConfig_GS.Instance.node_elements_style, GUILayout.ExpandWidth(true));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                //Action select dropdown
                if (GUILayout.Button("Change Action", UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    Vector2 mousePos = Event.current.mousePosition;
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new ActionSelectMenu_GS(null));
                }

                //Behaviour edit button
                if (GUILayout.Button("Edit Action", UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    ProTools.OpenScriptEditor(_target_agent.idle_action.GetType());
                }
            }
        }
コード例 #13
0
        private void DrawNodeWindowSetState()
        {
            GUILayout.BeginHorizontal();
            //Edit
            if (GUILayout.Button("Edit", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(30), GUILayout.ExpandWidth(true)))
            {
                //Set edit state
                _UI_mode = EditorUIMode.EDIT_STATE;
                //Reset window size
                _target_action_node.window_size = Vector2.zero;
            }
            //Delete
            if (GUILayout.Button("Delete", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(30), GUILayout.ExpandWidth(true)))
            {
                //Add delete node to accept menu delegates callback
                SecurityAcceptMenu_GS.on_accept_delegate += () => _target_action_node.agent.RemoveActionNode(_target_action_node);
                //Add delete node editor to accept menu delegates callback
                SecurityAcceptMenu_GS.on_accept_delegate += () => NodeEditor_GS.Instance.RemoveTargetAgentActionNodeEditor(this);
                //Add mark scene dirty to accept menu delegates callback
                SecurityAcceptMenu_GS.on_accept_delegate += () => EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());

                //Get mouse current position
                Vector2 mousePos = Event.current.mousePosition;
                //Open security accept menu on mouse position
                PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new SecurityAcceptMenu_GS());
            }
            GUILayout.EndHorizontal();

            //Separation
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Condition ---------------
            //Conditions Title
            GUILayout.BeginHorizontal("HelpBox");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Conditions", UIConfig_GS.Instance.node_elements_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            //Show current conditions
            for (int k = 0; k < _condition_editors_num; k++)
            {
                _condition_editors[k].DrawUI();
            }
            //Condition add button
            if (GUILayout.Button("Add Condition", UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
            {
                Vector2 mouse_pos = Event.current.mousePosition;
                mouse_pos = NodeEditor_GS.Instance.ZoomCoordsToScreenCoords(mouse_pos);
                PopupWindow.Show(new Rect(mouse_pos.x, mouse_pos.y, 0, 0), new PropertySelectMenu_GS(this, PropertyUIMode.IS_CONDITION));
            }
            //-------------------------

            //Separation
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Action ------------------
            //Action null case
            if (_action_editor == null)
            {
                //Action area
                GUILayout.BeginHorizontal("HelpBox");
                GUILayout.FlexibleSpace();
                GUILayout.Label("No Action", UIConfig_GS.center_big_white_style, GUILayout.ExpandWidth(true));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                //Action select dropdown
                if (GUILayout.Button("Set Action", UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
                {
                    Vector2 mousePos = Event.current.mousePosition;
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new ActionSelectMenu_GS(this));
                }
            }
            //Action set case
            else
            {
                //Action area
                GUILayout.BeginHorizontal("HelpBox");
                GUILayout.FlexibleSpace();
                GUILayout.Label(_target_action_node.action.name, UIConfig_GS.Instance.node_elements_style, GUILayout.ExpandWidth(true));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                //Draw selected action UI
                _action_editor.DrawUI();

                //Edit / Delete area
                GUILayout.BeginHorizontal();
                //Edit
                if (GUILayout.Button("Edit", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(30), GUILayout.ExpandWidth(true)))
                {
                    //Open target script code editor
                    ProTools.OpenScriptEditor(_target_action_node.action.GetType());
                }
                //Delete
                if (GUILayout.Button("Delete", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(30), GUILayout.ExpandWidth(true)))
                {
                    //Set action node action to null
                    _target_action_node.action = null;
                    //Set action editor to null
                    _action_editor = null;
                    //Resize node window
                    _target_action_node.window_size = Vector2.zero;
                    //Mark scene dirty
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                }
                GUILayout.EndHorizontal();
            }
            //-------------------------

            //Separation
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Effects -----------------
            //Effects Title
            GUILayout.BeginHorizontal("HelpBox");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Effects", UIConfig_GS.Instance.node_elements_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            //Show current effects
            for (int k = 0; k < _effect_editors_num; k++)
            {
                _effect_editors[k].DrawUI();
            }
            //Effect add button
            if (GUILayout.Button("Add Effect", UIConfig_GS.Instance.node_selection_buttons_style, GUILayout.Width(150), GUILayout.Height(20), GUILayout.ExpandWidth(true)))
            {
                Vector2 mousePos = Event.current.mousePosition;
                PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new PropertySelectMenu_GS(this, PropertyUIMode.IS_EFFECT));
            }
            //-------------------------

            GUI.DragWindow();
        }
コード例 #14
0
        private void DrawInShow()
        {
            GUILayout.BeginHorizontal();

            //Edit button, swap between edit and show state(hide on play)
            if (!Application.isPlaying)
            {
                if (GUILayout.Button("O", GUILayout.Width(30), GUILayout.Height(20), GUILayout.ExpandWidth(false)))
                {
                    //Initialize value
                    value = _target_property.value;
                    //Change UI mode
                    _UI_mode = EditorUIMode.EDIT_STATE;
                    //Allocate B var dropdown
                    _B_variable_dropdown = new ProTools.DropDownData_GS();
                    //Allocate operator dropdown
                    _operator_dropdown = new ProTools.DropDownData_GS();

                    //Get dropdown slots
                    _operator_dropdown.dropdown_slot   = ProTools.GetDropdownSlot();
                    _B_variable_dropdown.dropdown_slot = ProTools.GetDropdownSlot();

                    //Generate operators dropdown data
                    _operator_dropdown.paths = _valid_operators.ToShortStrings();
                    for (int k = 0; k < _valid_operators.Length; k++)
                    {
                        if (_valid_operators[k] == _target_property.operator_type)
                        {
                            ProTools.SetDropdownIndex(_operator_dropdown.dropdown_slot, k);
                            _operator_dropdown.selected_index = k;
                        }
                    }

                    //Get local blackboard variables keys with the same type
                    string[] local_keys = NodeEditor_GS.Instance.selected_agent.blackboard.GetKeysByVariableType(_target_property.variable_type);
                    //Get global blackboard variables keys with the same type
                    string[] global_keys = GlobalBlackboard_GS.blackboard.GetKeysByVariableType(_target_property.variable_type);

                    //Generate paths
                    _B_variable_dropdown.paths = new string[local_keys.Length + global_keys.Length];

                    //Add the local keys with a prefix for the dropdown
                    for (int k = 0; k < local_keys.Length; k++)
                    {
                        _B_variable_dropdown.paths[k] = "Local/" + local_keys[k];
                    }
                    //Add the global keys with a prefix for the dropdown
                    for (int k = local_keys.Length, i = 0; k < _B_variable_dropdown.paths.Length; k++, i++)
                    {
                        _B_variable_dropdown.paths[k] = "Global/" + global_keys[i];
                    }

                    //Search and set the already selected B key index
                    //Iterate avaliable B keys
                    for (int k = 0; k < _B_variable_dropdown.paths.Length; k++)
                    {
                        if (string.Compare(_B_variable_dropdown.paths[k], _target_property.B_key) == 0)
                        {
                            //When key is found save index and break the iteration
                            ProTools.SetDropdownIndex(_B_variable_dropdown.dropdown_slot, k);
                            _B_variable_dropdown.selected_index = k;
                            break;
                        }
                    }
                }
            }

            //A key label
            GUILayout.Label(_target_property.A_key, UIConfig_GS.center_normal_style, GUILayout.MaxWidth(200.0f), GUILayout.ExpandWidth(true));

            //Operator label
            GUILayout.Label(" " + _target_property.operator_type.ToShortString() + " ", GUILayout.MaxWidth(30.0f), GUILayout.ExpandWidth(true));

            //B value label
            if (string.IsNullOrEmpty(_target_property.B_key))
            {
                //Value case
                GUILayout.Label(_target_property.display_value, UIConfig_GS.center_normal_style, GUILayout.MaxWidth(200.0f), GUILayout.ExpandWidth(true));
            }
            else
            {
                //Variable case
                GUILayout.Label(_target_property.B_key, UIConfig_GS.center_normal_style, GUILayout.MaxWidth(200.0f), GUILayout.ExpandWidth(true));
            }

            //Delete button(hide on play)
            if (!Application.isPlaying)
            {
                if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.MaxWidth(25.0f)))
                {
                    //We need to check if the target property is a condition or an effect to delete it from the correct container
                    switch (_property_UI_mode)
                    {
                    case PropertyUIMode.IS_CONDITION:
                    {
                        //Add remove the current property from target action node conditions
                        SecurityAcceptMenu_GS.on_accept_delegate += () => _target_action_node_editor.target_action_node.RemoveCondition(_target_property);
                        //Add remove current property editor from target acton node editor conditions editors
                        SecurityAcceptMenu_GS.on_accept_delegate += () => _target_action_node_editor.RemoveConditionEditor(this);
                    }
                    break;

                    case PropertyUIMode.IS_EFFECT:
                    {
                        //Add remove the current property from target action node effects
                        SecurityAcceptMenu_GS.on_accept_delegate += () => _target_action_node_editor.target_action_node.RemoveEffect(_target_property);
                        //Add remove current property editor from target acton node editor effects editors
                        SecurityAcceptMenu_GS.on_accept_delegate += () => _target_action_node_editor.RemoveEffectEditor(this);
                        break;
                    }
                    }
                    //Get mouse current position
                    Vector2 mousePos = Event.current.mousePosition;
                    //Open security accept menu on mouse position
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new SecurityAcceptMenu_GS());
                }
            }

            GUILayout.EndHorizontal();
        }
コード例 #15
0
        private void ShowBindOptions()
        {
            //Bind variable
            GUILayout.BeginHorizontal();

            if (!_target_variable.is_field_binded && !_target_variable.is_method_binded)
            {
                //Free space margin
                GUILayout.FlexibleSpace();

                //Generate variable bind selection dropdown
                ProTools.GenerateButtonDropdownMenu(ref _variable_dropdown_data.selected_index, _variable_dropdown_data.display_paths, "V", false, 40.0f, _variable_dropdown_data.dropdown_slot);

                //Generate method bind selection dropdown
                ProTools.GenerateButtonDropdownMenu(ref _method_dropdown_data.selected_index, _method_dropdown_data.display_paths, "M", false, 40.0f, _method_dropdown_data.dropdown_slot);

                if (_variable_dropdown_data.selected_index > -1)
                {
                    //Bind variable to the new field using the selected path
                    EditorApplication.delayCall += () => _target_variable.BindField(_variable_dropdown_data.paths[_variable_dropdown_data.selected_index]);
                }
                else if (_method_dropdown_data.selected_index > -1)
                {
                    //Bind the variable to the new method using the selected path
                    EditorApplication.delayCall += () => _target_variable.BindMethod(_method_dropdown_data.paths[_method_dropdown_data.selected_index]);
                    EditorApplication.delayCall += () => _has_method_parameters = ProTools.FindMethodFromPath(_target_variable.binded_method_path, _target_variable.system_type, _target_blackboard.target_agent.gameObject).Key.GetParameters().Length > 0;
                }
            }
            else
            {
                //Show current variable bind
                if (target_variable.is_field_binded)
                {
                    GUILayout.Label(_target_variable.binded_field_short_path, GUILayout.MaxWidth(90.0f));
                }
                //Show current method bind
                else
                {
                    if (_has_method_parameters)
                    {
                        //If the variables is method binded we show the field inheritance path
                        if (GUILayout.Button(_target_variable.binded_method_short_path, GUILayout.MaxWidth(90.0f)))
                        {
                            Vector2 mousePos = Event.current.mousePosition;
                            PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new MethodSelectMenu_GS(_target_variable));
                        }
                    }
                    else
                    {
                        GUILayout.Label(_target_variable.binded_method_short_path, GUILayout.MaxWidth(90.0f));
                    }
                }

                //Free space margin
                GUILayout.FlexibleSpace();

                //UnBind button
                if (GUILayout.Button("UnBind", GUILayout.MaxWidth(50.0f)))
                {
                    if (_target_variable.is_field_binded)
                    {
                        //Unbind varaible resetting  getter/setter and field path
                        _target_variable.UnbindField();
                        //Reset path index in the variables dropdown
                        ProTools.SetDropdownIndex(_variable_dropdown_data.dropdown_slot, -1);
                    }
                    else
                    {
                        //Unbind method rersetting getter and method info
                        _target_variable.UnbindMethod();
                        _has_method_parameters = false;
                        //Reset path index in the methods dropdown
                        ProTools.SetDropdownIndex(_method_dropdown_data.dropdown_slot, -1);
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
コード例 #16
0
 public override void OnClose()
 {
     ProTools.FreeDropdownSlot(_action_dropdown_slot);
 }
コード例 #17
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            editorWindow.minSize = new Vector2(200.0f, 100.0f);
            editorWindow.maxSize = new Vector2(200.0f, 100.0f);

            GUILayout.BeginVertical();

            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Action Select", UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Action select dropdown button
            ProTools.GenerateButtonDropdownMenu(ref _selected_action_index, ResourcesTool.action_paths, "Select", false, 200.0f, _action_dropdown_slot);
            if (_selected_action_index != -1)
            {
                //Get selected action script value
                Object script = null;
                ResourcesTool.action_scripts.TryGetValue(ResourcesTool.action_paths[_selected_action_index], out script);
                //Allocate a class with the same type of script value
                Action_GS new_script = ProTools.AllocateClass <Action_GS>(script);
                //Action node case
                if (_target_action_node != null)
                {
                    //Check if the selected action is different to the node action
                    if (_target_action_node.action == null || _target_action_node.action.GetType() != new_script.GetType())
                    {
                        //Set the class name to the new allocated action
                        new_script.name = ResourcesTool.action_paths[_selected_action_index].PathToName();
                        //Set the allocated class to the action node
                        _target_action_node.action = new_script;
                        //Set new action agent
                        new_script.agent = _target_action_node.agent;
                        //Set target action node editor action editor
                        _target_action_node_editor.action_editor = new Action_GS_Editor(_target_action_node_editor);
                        //Mark scene dirty
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                        //Repaint the node editor to update the UI
                        NodeEditor_GS.Instance.Repaint();
                    }
                }
                //Agent idle action case
                else
                {
                    Agent_GS target_agent = NodeEditor_GS.Instance.selected_agent;
                    //Check if the selected agent is different to the agent idle action
                    if (target_agent.idle_action == null || target_agent.idle_action.GetType() != new_script.GetType())
                    {
                        //Set the class name to the new allocated action
                        new_script.name = ResourcesTool.action_paths[_selected_action_index].PathToName();
                        //Set new action agent
                        new_script.agent = NodeEditor_GS.Instance.selected_agent;
                        //Set the agent idle action
                        target_agent.idle_action = new_script;
                        //Mark scene dirty
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                        //Repaint the node editor to update the UI
                        NodePlanning_GS.Instance.Repaint();
                    }
                }
                //Close the pop window at the end of the process
                editorWindow.Close();
            }

            //Action create button
            if (GUILayout.Button("Create New", GUILayout.ExpandWidth(true)))
            {
                //Get mouse current position
                Vector2 mousePos = Event.current.mousePosition;
                //Open script creation menu
                PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new ScriptCreationMenu_GS(ScriptCreationMenu_GS.ScriptCreationType.ScriptC_action, _target_action_node.index));
            }

            GUILayout.EndVertical();
        }
コード例 #18
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            editorWindow.minSize = new Vector2(200.0f, 100.0f);
            editorWindow.maxSize = new Vector2(200.0f, 100.0f);

            GUILayout.BeginVertical();

            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Behaviour Select", UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Behaviour select dropdown button
            ProTools.GenerateButtonDropdownMenu(ref _selected_behaviour_index, ResourcesTool.behaviour_paths, "Select", false, 200.0f, _behaviour_dropdown_slot);
            if (_selected_behaviour_index != -1)
            {
                //Get selected behaviour script
                Object script = null;
                ResourcesTool.agent_behaviour_scripts.TryGetValue(ResourcesTool.behaviour_paths[_selected_behaviour_index], out script);
                //Allocate a class with the same type of script value
                AgentBehaviour_GS new_script = ProTools.AllocateClass <AgentBehaviour_GS>(script);
                //Check if the selected behaviour is different to the target agent one
                if (_target_agent.behaviour == null || new_script.GetType() != _target_agent.behaviour.GetType())
                {
                    //Set behaviour name
                    new_script.name = ResourcesTool.behaviour_paths[_selected_behaviour_index].PathToName();
                    //Set behaviour target agent
                    new_script.agent = _target_agent;
                    //Set agent behaviour
                    _target_agent.behaviour = new_script;
                    //Mark scene dirty
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                    //Repaint the node editor to update the UI
                    if (NodePlanning_GS.IsOpen())
                    {
                        NodePlanning_GS.Instance.Repaint();
                    }
                }
                //Close the pop window at the end of the process
                editorWindow.Close();
            }

            //Behaviour create button
            if (GUILayout.Button("Create New", GUILayout.ExpandWidth(true)))
            {
                //Add popup close on new behaviour script creation
                //ScriptCreationMenu_GS.on_script_creation_delegate += () => editorWindow.Close();

                //Get mouse current position
                Vector2 mousePos = Event.current.mousePosition;
                //Open script creation menu
                PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new ScriptCreationMenu_GS(ScriptCreationMenu_GS.ScriptCreationType.ScriptC_behaviour));
            }

            GUILayout.EndVertical();
        }
コード例 #19
0
 public override void OnClose()
 {
     ProTools.FreeDropdownSlot(_folder_dropdown_slot);
 }
コード例 #20
0
 public override void OnClose()
 {
     //Free dropdown slots
     ProTools.FreeDropdownSlot(_variable_dropdown_data.dropdown_slot);
 }
コード例 #21
0
        //Constructor =================
        public MethodSelectMenu_GS(Variable_GS target_variable)
        {
            //Set the target variable
            _target_variable = target_variable;
            //Get method info
            _target_method = ProTools.FindMethodFromPath(_target_variable.binded_method_path, target_variable.system_type, NodeEditor_GS.Instance.selected_agent.gameObject).Key;
            //Get method parameters
            method_parameters = _target_method.GetParameters();
            //Allocate input array in null case
            if (_target_variable.binded_method_input == null)
            {
                _target_variable.binded_method_input = new KeyValuePair <string, object> [method_parameters.Length];
                //Allocate input data from type

                for (int k = 0; k < method_parameters.Length; k++)
                {
                    KeyValuePair <string, object> input = _target_variable.binded_method_input[k];
                    if (string.IsNullOrEmpty(input.Key) && input.Value == null)
                    {
                        object temp_value = new object();
                        ProTools.AllocateFromVariableType(method_parameters[k].ParameterType.ToVariableType(), ref temp_value);
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>("", temp_value);
                    }
                }
            }
            //Allocate editor values and dropdowns
            local_values    = new object[method_parameters.Length];
            input_dropdowns = new ProTools.DropDownData_GS[method_parameters.Length];
            for (int k = 0; k < method_parameters.Length; k++)
            {
                //Initialize local value
                if (_target_variable.binded_method_input[k].Value != null)
                {
                    local_values[k] = _target_variable.binded_method_input[k].Value;
                }
                else
                {
                    ProTools.AllocateFromVariableType(method_parameters[k].ParameterType.ToVariableType(), ref local_values[k]);
                }

                //Generate the new dropdown data
                ProTools.DropDownData_GS new_dropdown = new ProTools.DropDownData_GS();
                new_dropdown.dropdown_slot = ProTools.GetDropdownSlot();

                //Get local and global variables
                string[] local_keys  = NodeEditor_GS.Instance.selected_agent.blackboard.GetKeysByVariableType(method_parameters[k].ParameterType.ToVariableType());
                string[] global_keys = GlobalBlackboard_GS.blackboard.GetKeysByVariableType(method_parameters[k].ParameterType.ToVariableType());

                //Generate dropdown paths
                new_dropdown.paths         = new string[local_keys.Length + global_keys.Length];
                new_dropdown.display_paths = new string[local_keys.Length + global_keys.Length];

                //Add the local keys with a prefix for the dropdown
                for (int j = 0; j < local_keys.Length; j++)
                {
                    new_dropdown.display_paths[j] = "Local/" + local_keys[j];
                    new_dropdown.paths[j]         = local_keys[j];
                }

                //Add the global keys with a prefix for the dropdown
                for (int j = local_keys.Length, s = 0; j < new_dropdown.paths.Length; j++, s++)
                {
                    new_dropdown.display_paths[j] = "Global/" + global_keys[s];
                    new_dropdown.paths[j]         = global_keys[s];
                }

                //Add the generated dropdown
                input_dropdowns[k] = new_dropdown;
            }
        }
コード例 #22
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Variable Select", UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            //Variable name field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", GUILayout.ExpandWidth(true));
            _variable_name = EditorGUILayout.TextField(_variable_name, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();

            //Variable type field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Type", GUILayout.ExpandWidth(true));
            VariableType current_type = _variable_type;

            _variable_type = (VariableType)EditorGUILayout.EnumPopup(_variable_type, GUILayout.Width(150), GUILayout.ExpandWidth(true));
            //Check if var type is changed
            if (current_type != _variable_type)
            {
                //Allocate value from variable type
                ProTools.AllocateFromVariableType(_variable_type, ref _variable_value);

                //Get all the properties in the agent gameobject
                PropertyInfo[] _properties_info = ProTools.FindConcretePropertiesInGameObject(NodeEditor_GS.Instance.selected_agent.gameObject, _variable_type.ToSystemType());
                //Get all fields in th agent gameobject
                FieldInfo[] _fields_info = ProTools.FindConcreteFieldsInGameObject(NodeEditor_GS.Instance.selected_agent.gameObject, _variable_type.ToSystemType());

                //Allocate strings arrays
                _variable_dropdown_data.paths         = new string[_properties_info.Length + _fields_info.Length];
                _variable_dropdown_data.display_paths = new string[_properties_info.Length + _fields_info.Length];
                //Generate properties paths
                for (int k = 0; k < _properties_info.Length; k++)
                {
                    _variable_dropdown_data.paths[k]         = string.Format("{0}.{1}", _properties_info[k].ReflectedType.FullName, _properties_info[k].Name);
                    _variable_dropdown_data.display_paths[k] = _variable_dropdown_data.paths[k].Replace('.', '/');
                }
                //Generate fields paths
                int fields_k = 0; //Index to iterate fields info array
                for (int k = _properties_info.Length; k < _properties_info.Length + _fields_info.Length; k++)
                {
                    _variable_dropdown_data.paths[k]         = string.Format("{0}.{1}", _fields_info[fields_k].ReflectedType.FullName, _fields_info[fields_k].Name);
                    _variable_dropdown_data.display_paths[k] = _variable_dropdown_data.paths[k].Replace('.', '/');
                    fields_k += 1;//Update fields index
                }
            }
            GUILayout.EndHorizontal();

            //Custom field value
            if (_variable_type != VariableType._undefined_var_type)
            {
                GUILayout.BeginVertical();

                //Show variable value or info label if the variable is binded
                if (_variable_dropdown_data.selected_index != -1)
                {
                    GUILayout.Label("Value=" + bind_selected_display_path, UIConfig_GS.Instance.node_elements_style, GUILayout.ExpandWidth(true));
                }
                else
                {
                    //Define horizontal area
                    GUILayout.BeginHorizontal(GUILayout.MaxWidth(150.0f));

                    //Value label
                    GUILayout.Label("Value", GUILayout.MaxWidth(40.0f));

                    //Generate an input field adapted to the type of the variable
                    ProTools.ValueFieldByVariableType(_variable_type, ref _variable_value);

                    GUILayout.EndHorizontal();
                }

                //Bind variable
                GUILayout.BeginHorizontal();
                //Generate bind selection dropdown

                /*ProTools.GenerateButtonDropdownMenu(ref _variable_dropdown_data.selected_index, _variable_dropdown_data.display_paths, "Bind", false, 90.0f, _variable_dropdown_data.dropdown_slot);
                 * //UnBind button
                 * if (GUILayout.Button("UnBind"))
                 * {
                 *  //Reset variable dropdown
                 *  ProTools.SetDropdownIndex(_variable_dropdown_data.dropdown_slot, -1);
                 * }
                 * GUILayout.EndHorizontal();
                 *
                 * //Show selected bind path
                 * if (_variable_dropdown_data.selected_index == -1) GUILayout.Label(bind_selected_display_path);*/

                GUILayout.EndVertical();
            }

            //Separation
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            //Add button
            if (GUILayout.Button("Add", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                //Add the new variable if the data is correct
                if (!string.IsNullOrEmpty(_variable_name) && _variable_type != VariableType._undefined_var_type && _variable_value != null)
                {
                    //Send info to the bb to generate the variable
                    Variable_GS new_variable = null;
                    //Local case
                    if (_global_blackboard == false)
                    {
                        new_variable = NodeEditor_GS.Instance.selected_agent.blackboard.AddVariable(_variable_name, _variable_type, _variable_value);
                    }
                    //Global case
                    else
                    {
                        new_variable = GlobalBlackboard_GS.blackboard.AddVariable(_variable_name, _variable_type, _variable_value);
                    }

                    //If add var return null is because the name is invalid(exists a variable with the same name)
                    if (new_variable != null)
                    {
                        //Check if var have to be bind
                        if (_variable_dropdown_data.selected_index != -1)
                        {
                            //Bind new variable
                            new_variable.BindField(_variable_dropdown_data.paths[_variable_dropdown_data.selected_index]);
                        }
                        //Send the new variable to the blackboard editor to generate the variable editor
                        //Local case
                        if (_global_blackboard == false)
                        {
                            NodeEditor_GS.Instance.blackboard_editor.AddVariableEditor(new_variable);
                        }
                        //Global case
                        else
                        {
                            GlobalBlackboard_GS_Editor.blackboard_editor.AddVariableEditor(new_variable);
                        }
                        //Close this popup and updat bb window
                        editorWindow.Close();
                        NodeEditor_GS.Instance.Repaint();
                    }
                    else
                    {
                        //Add a rep prefix to the variable name, so the user can see that the name is repeated
                        _variable_name = "Rep:" + _variable_name;
                    }
                }
            }
            //Close button
            if (GUILayout.Button("Close", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                editorWindow.Close();
            }
            GUILayout.EndHorizontal();
        }
コード例 #23
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Method Input", UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            GUILayout.BeginVertical();

            //Method name
            GUILayout.Label(_target_method.Name, UIConfig_GS.left_bold_style);

            //Method inputs
            for (int k = 0; k < method_parameters.Length; k++)
            {
                GUILayout.BeginHorizontal();

                //Input type
                GUILayout.Label(method_parameters[k].ParameterType.ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(80), GUILayout.ExpandWidth(true));
                //Not binded input case
                if (string.IsNullOrEmpty(_target_variable.binded_method_input[k].Key))
                {
                    //Input value
                    ProTools.ValueFieldByVariableType(method_parameters[k].ParameterType.ToVariableType(), ref local_values[k]);

                    //Bind dropdown
                    ProTools.GenerateButtonDropdownMenu(ref input_dropdowns[k].selected_index, input_dropdowns[k].display_paths, "Bind", false, 40.0f, input_dropdowns[k].dropdown_slot);

                    //On variable selected we update the method input of the target variable
                    if (input_dropdowns[k].selected_index > -1)
                    {
                        //Generate the new method input with the bind path
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>(input_dropdowns[k].display_paths[input_dropdowns[k].selected_index], null);
                    }
                }
                //Binded input case
                else
                {
                    //Binded input path
                    GUILayout.Label(_target_variable.binded_method_input[k].Key, GUILayout.MaxWidth(80.0f));
                    //Unbind button
                    if (GUILayout.Button("UnBind", GUILayout.MaxWidth(50.0f)))
                    {
                        //Remove method input path string and place tje local correct type value
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>("", local_values[k]);
                        //Reset the dropdown selected index
                        ProTools.SetDropdownIndex(input_dropdowns[k].dropdown_slot, -1);
                    }
                }
                //Binded input case
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();

            //Apply changes button
            if (GUILayout.Button("Apply", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                for (int k = 0; k < method_parameters.Length; k++)
                {
                    if (string.IsNullOrEmpty(_target_variable.binded_method_input[k].Key))
                    {
                        //Local object values are applied to the non binded method input parameters
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>("", local_values[k]);
                    }
                }

                //Release the allocated dropdown slots
                for (int k = 0; k < input_dropdowns.Length; k++)
                {
                    ProTools.FreeDropdownSlot(input_dropdowns[k].dropdown_slot);
                }

                //Close popupwindow
                editorWindow.Close();
            }

            //Close button
            if (GUILayout.Button("Close", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                //Release the allocated dropdown slots
                for (int k = 0; k < input_dropdowns.Length; k++)
                {
                    ProTools.FreeDropdownSlot(input_dropdowns[k].dropdown_slot);
                }

                //Close popupwindow
                editorWindow.Close();
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
コード例 #24
0
        public override bool InitializeMethodBinding(GameObject target_obj)
        {
            //Reset getter/setter
            getter = null;
            setter = null;

            //Get the target method instance
            KeyValuePair <MethodInfo, object> target_method = ProTools.FindMethodFromPath(_binded_method_path, system_type, target_obj);

            //In null instance case the variable is unbind
            if (target_method.Value == null)
            {
                Debug.LogError("Binded method not found!");

                UnbindMethod();
                return(false);
            }

            //Set method info
            _binded_method_info = target_method.Key;
            //Set method instance
            _binded_method_instance = target_method.Value;

            if (_binded_method_input == null)
            {
                _binded_method_input = new KeyValuePair <string, object> [0];
                if (_binded_method_info.GetParameters().Length > 0)
                {
                    Debug.LogError("The method binding " + _binded_method_info.Name + "needs input definition!");
                }
            }
            else
            {
                for (int k = 0; k < _binded_method_input.Length; k++)
                {
                    //Current input info
                    KeyValuePair <string, object> input = _binded_method_input[k];

                    //Binded value case
                    if (string.IsNullOrEmpty(input.Key) == false)
                    {
                        //Check if is a local or global variable
                        //Global case
                        string[] input_info = input.Key.Split('/'); //Input location and variable name
                        if (string.Compare(input_info[0], "Global") == 0)
                        {
                            _binded_method_input[k] = new KeyValuePair <string, object>(_binded_method_input[k].Key, GlobalBlackboard_GS.blackboard.GetObjectVariable(input_info[1]));
                        }
                        //Local case
                        else
                        {
                            _binded_method_input[k] = new KeyValuePair <string, object>(_binded_method_input[k].Key, target_obj.GetComponent <Agent_GS>().blackboard.GetObjectVariable(input_info[1]));
                        }
                    }
                    //Not binded value case
                    else if (input.Value == null)
                    {
                        Debug.LogError("The method bind process for the variable " + name + " has an input error in index " + k + " !");
                    }
                }
            }
            return(true);
        }
コード例 #25
0
        private void DrawInEdit()
        {
            GUILayout.BeginHorizontal();

            //Edit button, swap between edit and show state
            if (GUILayout.Button("-", GUILayout.Width(30), GUILayout.Height(20), GUILayout.ExpandWidth(false)) || Application.isPlaying)
            {
                //Change UI mode
                _UI_mode = EditorUIMode.SET_STATE;
                //Set input focus to null
                GUI.FocusControl("null");
                //Free dropdown slots
                ProTools.FreeDropdownSlot(_operator_dropdown.dropdown_slot);
                ProTools.FreeDropdownSlot(_B_variable_dropdown.dropdown_slot);
                _operator_dropdown   = null;
                _B_variable_dropdown = null;
                //Check B key
                if (edit_value)
                {
                    //If property B key is not ser property will use value
                    _target_property.B_key = null;
                    //If value is different we update the variable value
                    if (value != _target_property.value)
                    {
                        _target_property.value = value;
                    }
                    ;
                }
                return;
            }

            //A key label
            GUILayout.Label(_target_property.A_key, UIConfig_GS.center_normal_style, GUILayout.MaxWidth(200.0f), GUILayout.ExpandWidth(true));

            //Operator dropdown
            ProTools.GenerateButtonDropdownMenu(ref _operator_dropdown.selected_index, _operator_dropdown.paths, _operator_dropdown.paths[_operator_dropdown.selected_index], true, 30.0f, _operator_dropdown.dropdown_slot);
            //Check operator change
            if (_operator_dropdown.selected_index != -1 && _valid_operators[_operator_dropdown.selected_index] != _target_property.operator_type)
            {
                _target_property.operator_type = _valid_operators[_operator_dropdown.selected_index];
            }

            //Value area
            //First check if the target property uses a value or a variable
            if (edit_value)
            {
                //Generate UI field from type
                ProTools.ValueFieldByVariableType(_target_property.variable_type, ref value);

                //Change to variable button
                if (GUILayout.Button(new GUIContent(" ", "Change to variable"), GUILayout.MaxWidth(10.0f)))
                {
                    edit_value = false;
                }
            }
            else
            {
                //Generate enumerator popup with the avaliable B keys
                ProTools.GenerateButtonDropdownMenu(ref _B_variable_dropdown.selected_index, _B_variable_dropdown.paths, "Not Set", _B_variable_dropdown.selected_index != -1, 80.0f, _B_variable_dropdown.dropdown_slot);
                //Check B key change
                if (_B_variable_dropdown.selected_index != -1 && string.Compare(_target_property.B_key, _B_variable_dropdown.paths[_B_variable_dropdown.selected_index]) != 0)
                {
                    //Update B key on change
                    _target_property.B_key = _B_variable_dropdown.paths[_B_variable_dropdown.selected_index];
                    //Set value as B variable
                    string[] B_key_info = _target_property.B_key.Split('/');
                    if (string.Compare(B_key_info[0], "Global") == 0)
                    {
                        _target_property.value = GlobalBlackboard_GS.blackboard.GetObjectVariable(B_key_info[1]);
                    }
                    else
                    {
                        _target_property.value = NodeEditor_GS.Instance.selected_agent.blackboard.GetObjectVariable(B_key_info[1]);
                    }
                }

                //Change to value button
                if (GUILayout.Button(new GUIContent(" ", "Change to value"), GUILayout.MaxWidth(10.0f)))
                {
                    edit_value             = true;
                    _target_property.B_key = null;
                    ProTools.AllocateFromVariableType(_target_property.variable_type, ref value);
                }
            }
            GUILayout.EndHorizontal();
        }
コード例 #26
0
        private void DrawInShow()
        {
            GUILayout.BeginHorizontal();

            //Edit button, swap between edit and show state(hide on play)
            if (!Application.isPlaying)
            {
                if (GUILayout.Button(new GUIContent("O", "Change variable editor to edit mode"), GUILayout.Width(20), GUILayout.Height(20)))
                {
                    //Change UI mode
                    _UI_mode = EditorUIMode.EDIT_STATE;
                    //Set input focus to null
                    GUI.FocusControl("null");
                    //Set new name string
                    new_name = _target_variable.name;

                    //Generate bind options
                    //Generate variables paths and display paths

                    //Get all the properties in the agent gameobject
                    PropertyInfo[] _properties_info = ProTools.FindConcretePropertiesInGameObject(NodeEditor_GS.Instance.selected_agent.gameObject, _target_variable.system_type);
                    //Get all fields in th agent gameobject
                    FieldInfo[] _fields_info = ProTools.FindConcreteFieldsInGameObject(NodeEditor_GS.Instance.selected_agent.gameObject, _target_variable.system_type);

                    //Allocate strings arrays
                    _variable_dropdown_data.paths         = new string[_properties_info.Length + _fields_info.Length];
                    _variable_dropdown_data.display_paths = new string[_properties_info.Length + _fields_info.Length];
                    //Generate properties paths
                    for (int k = 0; k < _properties_info.Length; k++)
                    {
                        _variable_dropdown_data.paths[k]         = string.Format("{0}.{1}", _properties_info[k].ReflectedType.FullName, _properties_info[k].Name);
                        _variable_dropdown_data.display_paths[k] = _variable_dropdown_data.paths[k].Replace('.', '/');
                    }
                    //Generate fields paths
                    for (int k = _properties_info.Length, fields_k = 0; k < _properties_info.Length + _fields_info.Length; k++, fields_k++)
                    {
                        _variable_dropdown_data.paths[k]         = string.Format("{0}.{1}", _fields_info[fields_k].ReflectedType.FullName, _fields_info[fields_k].Name);
                        _variable_dropdown_data.display_paths[k] = _variable_dropdown_data.paths[k].Replace('.', '/');
                    }

                    //Get dropdown slot
                    if (_variable_dropdown_data.dropdown_slot == -2)
                    {
                        _variable_dropdown_data.dropdown_slot = ProTools.GetDropdownSlot();
                    }

                    //Generate methods paths and display paths

                    //Get all the methods in the agent gameobject
                    KeyValuePair <MethodInfo, object>[] gameobject_data = ProTools.FindConcreteGameObjectMethods(NodeEditor_GS.Instance.selected_agent.gameObject, _target_variable.system_type);

                    //Get all the methods in the agent logic(actions, behaviour)
                    KeyValuePair <MethodInfo, object>[] agent_data = ProTools.FindConcreteAgentMethods(NodeEditor_GS.Instance.selected_agent, _target_variable.system_type);

                    //Allocate strings arrays
                    _method_dropdown_data.paths         = new string[gameobject_data.Length + agent_data.Length];
                    _method_dropdown_data.display_paths = new string[gameobject_data.Length + agent_data.Length];

                    //Generate gameobject methods
                    for (int k = 0; k < gameobject_data.Length; k++)
                    {
                        _method_dropdown_data.paths[k]         = string.Format("{0}.{1}.{2}", "GameObject", gameobject_data[k].Key.ReflectedType.FullName, gameobject_data[k].Key.Name);
                        _method_dropdown_data.display_paths[k] = _method_dropdown_data.paths[k].Replace('.', '/');
                    }

                    //Generate agent methods
                    for (int k = gameobject_data.Length, agent_k = 0; k < gameobject_data.Length + agent_data.Length; k++, agent_k++)
                    {
                        _method_dropdown_data.paths[k]         = string.Format("{0}.{1}.{2}", "Agent", agent_data[agent_k].Key.ReflectedType.FullName, agent_data[agent_k].Key.Name);
                        _method_dropdown_data.display_paths[k] = _method_dropdown_data.paths[k].Replace('.', '/');
                    }

                    //Get dropdown slot
                    if (_method_dropdown_data.dropdown_slot == -2)
                    {
                        _method_dropdown_data.dropdown_slot = ProTools.GetDropdownSlot();
                    }
                }
            }

            //Show variable type
            GUILayout.Label(_target_variable.type.ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(60.0f));

            //Show variable name
            GUILayout.Label(_target_variable.name, GUILayout.MaxWidth(110.0f));

            //Show variable value
            //Non binded variable case
            if (_target_variable.is_field_binded)
            {
                //If the variables is field binded we show the field inheritance path
                GUILayout.Label(_target_variable.binded_field_short_path, GUILayout.MaxWidth(90.0f));
            }
            else if (_target_variable.is_method_binded)
            {
                if (_has_method_parameters)
                {
                    //If the variables is method binded we show the field inheritance path
                    if (GUILayout.Button(_target_variable.binded_method_short_path, GUILayout.MaxWidth(90.0f)))
                    {
                        Vector2 mousePos = Event.current.mousePosition;
                        PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new MethodSelectMenu_GS(_target_variable));
                    }
                }
                else
                {
                    GUILayout.Label(_target_variable.binded_method_short_path, GUILayout.MaxWidth(90.0f));
                }
            }
            //Binded variable case
            else
            {
                //Get variable value
                object value = _target_variable.object_value;
                //Generate UI field from type
                ProTools.ValueFieldByVariableType(_target_variable.type, ref value);
                //If value is different we update the variable value
                if (value.Equals(_target_variable.object_value) == false)
                {
                    _target_variable.value = value;
                }
                ;
            }

            //Variable planning value
            GUILayout.Label("Pv", GUILayout.MaxWidth(20));
            _target_variable.planning_value = EditorGUILayout.FloatField((float)_target_variable.planning_value, GUILayout.MaxWidth(20.0f));

            //Remove button
            if (!Application.isPlaying)
            {
                if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.Height(20)))
                {
                    bool global = _target_blackboard.target_agent == null;

                    //Add remove the current var method to accept menu delegates callback
                    SecurityAcceptMenu_GS.on_accept_delegate += () => _target_blackboard.RemoveVariable(_target_variable.name, global);
                    //Add remove current var editor from blackboard editor to accept menu delegates calback
                    if (_target_blackboard == GlobalBlackboard_GS.blackboard)
                    {
                        SecurityAcceptMenu_GS.on_accept_delegate += () => GlobalBlackboard_GS_Editor.blackboard_editor.RemoveVariableEditor(_target_variable.name, global);
                    }
                    else
                    {
                        SecurityAcceptMenu_GS.on_accept_delegate += () => NodeEditor_GS.Instance.blackboard_editor.RemoveVariableEditor(_target_variable.name, global);
                    }
                    //Get mouse current position
                    Vector2 mousePos = Event.current.mousePosition;
                    //Open security accept menu on mouse position
                    PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new SecurityAcceptMenu_GS());
                }
            }

            GUILayout.EndHorizontal();
        }
コード例 #27
0
        private void DrawInEdit()
        {
            GUILayout.BeginVertical();

            //Values local data
            int    values_index  = 0;
            object current_value = null;

            //Hide button
            if (GUILayout.Button("Hide Config"))
            {
                _UI_mode = EditorUIMode.HIDE_STATE;
                //Reset action node window to readapt it
                _target_node_editor.target_action_node.window_size = Vector2.zero;
            }

            //Draw properties
            if (_properties.Length > 0)
            {
                //Title
                GUILayout.Label("Properties:");
                //Iterate the previously selected properties
                for (int k = 0; k < _properties.Length; k++)
                {
                    GUILayout.BeginHorizontal();

                    //Scope current value
                    current_value = _values[values_index];

                    if (current_value == null)
                    {
                        if (_properties[k].CanRead == false)
                        {
                            //Only write type
                            GUILayout.Label("no_getter", UIConfig_GS.left_bold_style, GUILayout.MaxWidth(80.0f));
                            //Property name string
                            GUILayout.Label(_properties[k].Name, GUILayout.MaxWidth(100.0f));
                        }
                        else
                        {
                            //In null case show error message
                            GUILayout.Label(_properties[k].Name + " = null", UIConfig_GS.left_bold_red_style);
                        }
                    }
                    else
                    {
                        //Property type string
                        GUILayout.Label(current_value.GetType().ToVariableType().ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(80.0f));
                        //Property name string
                        GUILayout.Label(_properties[k].Name, GUILayout.MaxWidth(100.0f));
                        //Property value
                        if (_properties[k].CanWrite)
                        {
                            //Defined setter case
                            //Generate property UI
                            ProTools.ValueFieldByVariableType(current_value.GetType().ToVariableType(), ref _values[values_index]);
                            //Set property input
                            if (current_value.Equals(_values[values_index]) == false)
                            {
                                _properties[k].GetSetMethod().Invoke(_target_action, new object[] { _values[values_index] });
                            }
                        }
                        else
                        {
                            //Non defined setter case
                            GUILayout.Label(current_value.ToString(), GUILayout.MaxWidth(70.0f));
                        }
                    }

                    //Update values index
                    values_index += 1;

                    GUILayout.EndHorizontal();
                }
            }

            //Draw fields
            if (_fields.Length > 0)
            {
                //Title
                GUILayout.Label("Fields:");
                //Iterate the previously selected fields
                for (int k = 0; k < _fields.Length; k++)
                {
                    GUILayout.BeginHorizontal();

                    //Scope current value
                    current_value = _values[values_index];

                    //In null case show error message
                    if (current_value == null)
                    {
                        GUILayout.Label(_fields[k].Name + " = null", UIConfig_GS.left_bold_red_style);
                    }
                    else
                    {
                        //Field type string
                        GUILayout.Label(current_value.GetType().ToVariableType().ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(80.0f));
                        //Field name string
                        GUILayout.Label(_fields[k].Name, GUILayout.MaxWidth(100.0f));
                        //Field value
                        //Generate field UI
                        ProTools.ValueFieldByVariableType(current_value.GetType().ToVariableType(), ref _values[values_index]);
                        //Set field input
                        if (current_value.Equals(_values[values_index]) == false)
                        {
                            _fields[k].SetValue(_target_action, _values[values_index]);
                        }
                    }
                    GUILayout.EndHorizontal();

                    //Update values index
                    values_index += 1;
                }
            }

            GUILayout.EndVertical();
        }