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();
        }
Example #2
0
 //Functionality Methods =======
 public void Hide()
 {
     if (_UI_mode != EditorUIMode.HIDE_STATE)
     {
         _UI_mode = EditorUIMode.HIDE_STATE;
     }
 }
Example #3
0
 private void DrawHide()
 {
     if (GUILayout.Button("Configure Action"))
     {
         ActionNode_GS_Editor[] action_nodes_editors = NodeEditor_GS.Instance.action_node_editors;
         int num = NodeEditor_GS.Instance.action_node_editors_num;
         for (int k = 0; k < num; k++)
         {
             if (action_nodes_editors[k].action_editor != null)
             {
                 action_nodes_editors[k].action_editor.Hide();
             }
         }
         _UI_mode = EditorUIMode.EDIT_STATE;
     }
 }
Example #4
0
        private void DrawNodeWindowEditState()
        {
            //Node name text field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name");
            _target_action_node.name = GUILayout.TextField(_target_action_node.name, GUILayout.Width(90), GUILayout.ExpandWidth(true));
            if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
            {
                _target_action_node.name = "";
            }
            GUILayout.EndHorizontal();

            //Node description text field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Description");
            string prev_description = _target_action_node.description;

            _target_action_node.description = GUILayout.TextArea(_target_action_node.description, GUILayout.Width(250), GUILayout.ExpandWidth(true));
            if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.ExpandWidth(true)))
            {
                _target_action_node.description = "";
            }
            //Check if description has been modified
            if (_target_action_node.description != prev_description)
            {
                //Generate new description ui content
                _description_label = new GUIContent(_target_action_node.description);
                //Calculate new ui content size
                _label_size = UIConfig_GS.left_white_style.CalcSize(_description_label);
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            //Close edit mode
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Close", UIConfig_GS.Instance.node_modify_button_style, GUILayout.Width(120), GUILayout.ExpandWidth(true)))
            {
                _UI_mode = EditorUIMode.SET_STATE;
                //Reset window size
                _target_action_node.window_size = Vector2.zero;
            }
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
        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();
        }
        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();
        }
        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();
        }
Example #8
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();
        }
Example #9
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();
        }