예제 #1
0
        void DrawStateContent(artConfigurationData configData)
        {
            GUILayout.BeginArea(WinRect);

            var rect = EditorGUILayout.BeginVertical();

            GUI.Box(rect, GUIContent.none);

            //GUI.color = Color.white;

            GUILayout.Space(2);
            GUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.Label(this.WindowStateAlias);
            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            GUILayout.EndArea();

            //Handles.EndGUI();
        }
예제 #2
0
        void DrawCurrentRunningState(artConfigurationData configData)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject;

            GameObject   gameObj = null;
            iMachineBase stateMachine;

            if (theStateMachineEditor.SelectedObj is GameObject)
            {
                gameObj      = (GameObject)theStateMachineEditor.SelectedObj;
                stateMachine = gameObj.GetComponent <iMachineBase>();
            }
            else
            {
                stateMachine = (iMachineBase)theStateMachineEditor.SelectedObj;
            }
            string currentClassName = stateMachine.GetCurrentState().GetType().ToString();

            currentClassName = utlDataAndFile.GetAfter(currentClassName, ".");

            if (currentClassName == this.ClassName)
            {
                Rect drawRect = new Rect(WinRect.x - configData.DebugBoxSize,
                                         WinRect.y - configData.DebugBoxSize,
                                         WinRect.width + (configData.DebugBoxSize * 2),
                                         WinRect.height + (configData.DebugBoxSize * 2));
                artGUIUtils.DrawRect(drawRect, configData.DebugBoxLineSize, configData.DebugBoxLineColor, configData.DebugBoxColor);
            }
            //theStateMachineEditor.EditorRepaint();
        }
예제 #3
0
        public void Update(baseState state, utlMatrix34 mtx, artConfigurationData configData)
        {
            m_State = state;

            MoveBool = false;

            // input
            Event ev = Event.current;

            //stateEditorUtils.MousePos = ev.mousePosition;

            //if the mouse button is down.
            if (ev.type == EventType.MouseDown && ev.button == 0)
            {
                LeftMouseButton = true;
                if (m_MainBodyHover)
                {
                    MoveBool = true;
                    Selected = true;
                }

                if (m_ResizeBodyHover)
                {
                    this.Resize = true;
                }
                if (this.m_TitleHover)
                {
                    RenameBool = true;
                }
            }

            if (ev.type == EventType.MouseUp)
            {
                LeftMouseButton = false;
                Selected        = false;
                Resize          = false;
                //RenameBool = false;
            }

            //GUI.Window(m_Id, mtx.Transform(WinRect), DrawNodeWindow, m_WindowStateAlias);


            Vector3 startPos = GetStartPosForConditional();

            for (int i = 0; i < this.ConditionLineList.Count; i++)
            {
                Vector3 endPos = GetEndPosForConditional(ConditionLineList[i]);

                Color shadowCol = new Color(0, 0, 1, 0.06f);
                //artGUIUtils.DrawArrowTranformed(mtx, startPos, endPos, WinRect, ConditionLineList[i].WinRect, 1, Color.black, 1, shadowCol, Color.white);
                artGUIUtils.DrawArrowTranformed(mtx, startPos, endPos, WinRect, ConditionLineList[i].WinRect, configData.ArrowLineWidth, configData.ArrowLineColor, configData.ArrowFillColor);
            }
            DrawCurrentRunningState(configData);
            DrawNodeWindow(this.m_Id, configData);
            //DrawCurrentRunningState();
        }
예제 #4
0
        public static void DrawGridBackground(artConfigurationData configData)
        {
            //Color shadowCol = new Color(0, 0, 0, 0.2f);

            stateEditorDrawUtils.DrawGridBackground(new Vector2(configData.MainWindowGridSize.x, configData.MainWindowGridSize.x),
                                                    new Vector2(configData.MainWindowGridSize.y, configData.MainWindowGridSize.y),
                                                    new Vector2(configData.SmallSquareGridSize.x, configData.SmallSquareGridSize.y),
                                                    configData.SmallSquareGridLineWidth,
                                                    configData.LineShadowColor);
            //Color blueCol = new Color(0, 0, 1, 0.4f);
            //stateEditorDrawUtils.DrawGridBackground(new Vector2(-5000, -5000), new Vector2(5000, 5000), new Vector2(250, 250), 3, blueCol);

            stateEditorDrawUtils.DrawGridBackground(new Vector2(configData.MainWindowGridSize.x, configData.MainWindowGridSize.x),
                                                    new Vector2(configData.MainWindowGridSize.y, configData.MainWindowGridSize.y),
                                                    new Vector2(configData.BigSqureGridSize.x, configData.BigSqureGridSize.y),
                                                    configData.BigSquareGridLineWidth,
                                                    configData.LineColor);

            //stateEditorDrawUtils.DrawGridBackground(new Vector2(-5000, -5000), new Vector2(5000, 5000), new Vector2(250, 250), 1, blueCol);
        }
예제 #5
0
        /// <summary>
        /// Draws the "Display" window of this window.  Everything is active.
        /// </summary>
        /// <param name="id"></param>
        void DrawNodeWindow(int id, artConfigurationData configData)
        {
            if (Event.current.button == 0 && Event.current.isMouse && ResizeBodyHover)
            {
            }

            if (Event.current.button == 1 && Event.current.isMouse)
            {
                //if (m_State != null && m_State is editorDisplayWindowsState)
                ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject;
                if (IsWithinUsingPanZoomTransform(Event.current.mousePosition, theStateMachineEditor.TransMtx))
                {
                    artDisplayWindowsBaseState dState = (artDisplayWindowsBaseState)m_State;
                    if (dState != null && Event.current.type == EventType.MouseDown && dState.DrawMenuBool)
                    {
                        GenericMenu menu = new GenericMenu();
                        for (int i = 0; i < configData.ConditionalCopyInfo.Length; i++)
                        {
                            menu.AddItem(new GUIContent("Add Conditional/" + configData.ConditionalCopyInfo[i].m_MenuString),
                                         false,
                                         dState.AddConditionalCallback,
                                         new conditionalSelection(this, i));
                        }

                        /* 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, this.RefactorClassCallback, this);
                        //stateEditorUtils.SelectedNode = this;
                        menu.ShowAsContext();
                        Event.current.Use();
                    }
                    //Debug.Log("--------------------------------------");
                    return;
                }
            }

            //draws background and outline.
            //int lineWidth = 2;

            /*          Color lineColor = new Color(0, 0.3f, 0, 1);
             *        Color backGroundColor = new Color(0.0f, 0.8f, 0.8f, 1.0f);*/

            Rect rect = new Rect(m_WinRect.x, m_WinRect.y, WinRect.width, WinRect.height);

            artGUIUtils.DrawRect(rect, configData.WindowOutlineLineWidth, configData.WindowLineColor, configData.StateWindowColor);


            DrawStateContent(configData);


            //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(WinRect.x + WinRect.width - (xOffset + (boxSize * 0.5f)), WinRect.y + yOffset - (boxSize * 0.5f), boxSize, boxSize);
            if (m_CloseButtonRect.Contains(Event.current.mousePosition))
            {
                artGUIUtils.DrawRect(m_CloseButtonRect, 2, Color.black, Color.red);
                if (Event.current.button == 0 && Event.current.isMouse)
                {
                    ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject;
                    theStateMachineEditor.DeleteStateBool  = true;
                    theStateMachineEditor.DeleteStateClass = ClassName;
                }
            }
            else
            {
                artGUIUtils.DrawRect(m_CloseButtonRect, 2, Color.black, Color.clear);
            }

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

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

            artGUIUtils.DrawWindowSizer(new Vector3(WinRect.x + WinRect.width - 2, WinRect.y + this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey);
            sizerSize = 10;
            artGUIUtils.DrawWindowSizer(new Vector3(WinRect.x + WinRect.width - 2, WinRect.y + this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey);
            sizerSize = 5;
            artGUIUtils.DrawWindowSizer(new Vector3(WinRect.x + WinRect.width - 2, WinRect.y + 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(WinRect.x, WinRect.y + titleHeight, WinRect.width, WinRect.height - initSizerSize - titleHeight);
            //m_MainBodyRectB = new Rect(WinRect.x, WinRect.y + titleHeight, WinRect.width - initSizerSize, WinRect.y - 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.x + WinRect.width - initSizerSize, WinRect.y + WinRect.height - initSizerSize, initSizerSize, initSizerSize));
            EditorGUIUtility.AddCursorRect(m_ResizeBodyRect, MouseCursor.ResizeUpLeft);

            //title
            const float rightMarginSize = 15;

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

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

            //DrawStateContent();

            UpdateMouseHover(Event.current.mousePosition);

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

            //GUI.DragWindow();
        }