Ejemplo n.º 1
0
 /// <summary>
 /// copies the a selected statemachine
 /// </summary>
 void OnCopyStateMachine()
 {
     if (m_CurrentState.m_StateName == "Display Windows" && stateEditorUtils.GameObject != null)
     {
         editorDisplayWindowsState theState = (editorDisplayWindowsState)CurrentState;
         theState.CopyStateMachine = true;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Callback to save the metadata for the window system.
        /// </summary>
        void OnSaveMetaData()
        {
            if (CurrentState is editorDisplayWindowsState)
            {
                editorDisplayWindowsState theState = (editorDisplayWindowsState)CurrentState;
                theState.Save = true;
            }

            for (int i = 0; i < stateEditorUtils.StateList.Count; i++)
            {
                stateEditorUtils.StateList[i].SaveMetaData();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Test conditionals are placed here.
        /// </summary>
        /// <param name="state"></param>
        /// <returns>true or false depending if transition conditions are met.</returns>
        public override string UpdateConditionalTest(baseState state)
        {
            string strOut = null;

            editorDisplayWindowsState theState = (editorDisplayWindowsState)state;

            if (theState.Save)
            {
                strOut = m_ChangeStateName;
            }

            return(strOut);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Test conditionals are placed here.
        /// </summary>
        /// <param name="state"></param>
        /// <returns>true or false depending if transition conditions are met.</returns>
        public override string UpdateConditionalTest(baseState state)
        {
            string strOut = null;

#if UNITY_EDITOR
            editorDisplayWindowsState theState = (editorDisplayWindowsState)state;

            if (theState.CopyStateMachine)
            {
                strOut = m_ChangeStateName;
            }
#endif
            return(strOut);
        }
        /// <summary>
        /// Test conditionals are placed here.
        /// </summary>
        /// <param name="state"></param>
        /// <returns>true or false depending if transition conditions are met.</returns>
        public override string UpdateConditionalTest(baseState state)
        {
            string strOut = null;

#if ARTIMECH_THIS_SHOULD_NEVER_BE_TRUE_BUT_IS_AN_EXAMPLE_OF_A_CONDITION_BEING_TRUE
            This is an example of setting a contition to true if the gameobject
            falls below a certain height ingame.
            if (state.m_GameObject.transform.position.y <= 1000)
            {
                strOut = m_ChangeStateName;
            }
#endif
            editorDisplayWindowsState theState = (editorDisplayWindowsState)state;
            if (theState.RefactorClass)
            {
                strOut = m_ChangeStateName;
            }

            return(strOut);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draws the "Display" window of this window.  Everything is active.
        /// </summary>
        /// <param name="id"></param>
        void DrawNodeWindow(int id)
        {
            if (Event.current.button == 1 && Event.current.isMouse)
            {
                if (m_State != null && m_State is editorDisplayWindowsState)
                {
                    editorDisplayWindowsState dState = (editorDisplayWindowsState)m_State;
                    if (dState != null && Event.current.type == EventType.MouseDown)
                    {
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Add Conditional/Empty Conditional"),
                                     false,
                                     dState.AddConditionalCallback,
                                     new editorDisplayWindowsState.menuData("Assets/Scripts/Common/statemachine/state_examples/stateConditionalTemplate.cs", "stateConditionalTemplate"));

                        menu.AddItem(new GUIContent("Add Conditional/Subscription Conditional"),
                                     false,
                                     dState.AddConditionalCallback,
                                     new editorDisplayWindowsState.menuData("Assets/Scripts/Common/statemachine/state_examples/stateCondSubExample.cs", "stateCondSubExample"));

                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Edit Script"), false, dState.EditScriptCallback, this);
                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Refactor State Class"), false, dState.RefactorClassCallback, this);
                        stateEditorUtils.SelectedNode = this;
                        menu.ShowAsContext();
                        Event.current.Use();
                    }
                    //Debug.Log("--------------------------------------");
                    return;
                }
            }

            //draw the exit button in the title bar
            Color shadowCol = new Color(0, 0, 0, 0.2f);
            float xOffset   = 8.0f;
            float yOffset   = 9.0f;
            float boxSize   = 8;

            //create the close button rectangle
            m_CloseButtonRect = new Rect(this.WinRect.width - (xOffset + (boxSize * 0.5f)), yOffset - (boxSize * 0.5f), boxSize, boxSize);

            //EditorGUI.DrawRect(closeBoxRect, new Color(0.9f, 0.9f, 0.9f));

            if (m_CloseButtonRect.Contains(Event.current.mousePosition))
            {
                stateEditorDrawUtils.DrawCubeFilled(new Vector3(WinRect.width - xOffset, yOffset, 0), boxSize, 1, Color.black, 1, shadowCol, Color.red);
            }
            else
            {
                stateEditorDrawUtils.DrawCubeFilled(new Vector3(WinRect.width - xOffset, yOffset, 0), boxSize, 1, Color.black, 1, shadowCol, new Color(0.9f, 0.9f, 0.9f));
            }

            stateEditorDrawUtils.DrawX(new Vector3(WinRect.width - (xOffset * 0.95f), yOffset * 0.95f, 0), boxSize - 1, boxSize - 1, 2, shadowCol);
            stateEditorDrawUtils.DrawX(new Vector3(WinRect.width - (xOffset * 1.0f), yOffset * 1.0f, 0), boxSize - 1, boxSize - 1, 1, Color.black);

            //draw the resizer
            const float initSizerSize = 15;
            float       sizerSize     = initSizerSize;

            stateEditorDrawUtils.DrawWindowSizer(new Vector3(WinRect.width - 2, this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey);
            sizerSize = 10;
            stateEditorDrawUtils.DrawWindowSizer(new Vector3(WinRect.width - 2, this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey);
            sizerSize = 5;
            stateEditorDrawUtils.DrawWindowSizer(new Vector3(WinRect.width - 2, this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey);

            const float titleHeight = 15;

            //create the main body rectangle.
            m_MainBodyRectA = new Rect(0, titleHeight, WinRect.width, WinRect.height - initSizerSize - titleHeight);
            m_MainBodyRectB = new Rect(0, titleHeight, WinRect.width - initSizerSize, WinRect.height);

            //main body of the window
            EditorGUIUtility.AddCursorRect(m_MainBodyRectA, MouseCursor.MoveArrow);
            EditorGUIUtility.AddCursorRect(m_MainBodyRectB, MouseCursor.MoveArrow);

            //resize
            m_ResizeBodyRect = new Rect(new Rect(WinRect.width - initSizerSize, WinRect.height - initSizerSize, initSizerSize, initSizerSize));
            EditorGUIUtility.AddCursorRect(m_ResizeBodyRect, MouseCursor.ResizeUpLeft);

            //title
            const float rightMarginSize = 15;

            m_TitleRect = new Rect(0, 0, WinRect.width - rightMarginSize, titleHeight);
            EditorGUIUtility.AddCursorRect(m_TitleRect, MouseCursor.Text);

            //close box
            EditorGUIUtility.AddCursorRect(m_CloseButtonRect, MouseCursor.ArrowMinus);

            UpdateMouseHover(Event.current.mousePosition);

            //stateEditorDrawUtils.DrawX(m_LinePos, 10, 10, 1, Color.black);

            GUI.DragWindow();
        }