Beispiel #1
0
        //Constructors ================
        public ActionNode_GS_Editor(ActionNode_GS new_target)
        {
            //Set targets
            _target_action_node = new_target;
            //Generate new description ui content
            _description_label = new GUIContent(_target_action_node.description);
            //Calculate new ui content size

            //Allocate condition editors array
            _condition_editors = new Property_GS_Editor[ProTools.INITIAL_ARRAY_SIZE];
            //Generate conditions UI
            for (int k = 0; k < _target_action_node.conditions_num; k++)
            {
                AddConditionEditor(_target_action_node.conditions[k]);
            }
            //Allocate effect editors array
            _effect_editors = new Property_GS_Editor[ProTools.INITIAL_ARRAY_SIZE];
            //Generate conditions UI
            for (int k = 0; k < _target_action_node.effects_num; k++)
            {
                AddEffectEditor(_target_action_node.effects[k]);
            }
            //Allocate action editor
            if (_target_action_node.action != null)
            {
                _action_editor = new Action_GS_Editor(this);
            }
        }
Beispiel #2
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();
        }