Exemplo n.º 1
0
 private static void ShowEditor()
 {
     _editor         = GetWindow <BrixEditor>();
     _editor.minSize = new Vector2(800, 600);
 }
Exemplo n.º 2
0
        public override void DrawWindow(Node inputNode)
        {
            if (inputNode.stateRef.currentState == null)
            {
                EditorGUILayout.LabelField("Add state to modify:");
            }
            else
            {
                if (inputNode.collapse)
                {
                    inputNode.windowRect.height = 100;
                }

                inputNode.collapse = EditorGUILayout.Toggle(" ", inputNode.collapse);
            }

            inputNode.stateRef.currentState =
                (State)EditorGUILayout.ObjectField(inputNode.stateRef.currentState, typeof(State), false);

            inputNode.previousCollapse = inputNode.collapse;

            if (inputNode.stateRef.previousState != inputNode.stateRef.currentState)
            {
                inputNode.isDuplicate            = BrixEditor.Settings.currentGraph.IsStateDuplicate(inputNode);
                inputNode.stateRef.previousState = inputNode.stateRef.currentState;

                if (!inputNode.isDuplicate)
                {
                    var pos = new Vector3(inputNode.windowRect.x, inputNode.windowRect.y, 0);
                    pos.x += inputNode.windowRect.width * 2;

                    SetupReordableLists(inputNode);

                    //Load transtions
                    for (var i = 0; i < inputNode.stateRef.currentState.transitions.Count; i++)
                    {
                        pos.y += i * 100;
                        BrixEditor.AddTransitionNodeFromTransition(
                            inputNode.stateRef.currentState.transitions[i], inputNode, pos);
                    }

                    BrixEditor.ForceSetDirty = true;
                }
            }

            if (inputNode.isDuplicate)
            {
                EditorGUILayout.LabelField("State is a duplicate!");
                inputNode.windowRect.height = 100;
                return;
            }

            if (inputNode.stateRef.currentState != null)
            {
                inputNode.isAssigned = true;

                if (inputNode.collapse)
                {
                    return;
                }

                if (inputNode.stateRef.serializedState == null)
                {
                    SetupReordableLists(inputNode);
                }

                float standard = 150;
                inputNode.stateRef.serializedState.Update();
                inputNode.showActions = EditorGUILayout.Toggle("Show Actions ", inputNode.showActions);
                if (inputNode.showActions)
                {
                    EditorGUILayout.LabelField("");
                    inputNode.stateRef.onFixedList.DoLayoutList();
                    EditorGUILayout.LabelField("");
                    inputNode.stateRef.onUpdateList.DoLayoutList();
                    standard +=
                        100 + 40 + (inputNode.stateRef.onUpdateList.count + inputNode.stateRef.onFixedList.count) * 20;
                }

                inputNode.showEnterExit = EditorGUILayout.Toggle("Show Enter/Exit ", inputNode.showEnterExit);
                if (inputNode.showEnterExit)
                {
                    EditorGUILayout.LabelField("");
                    inputNode.stateRef.onEnterList.DoLayoutList();
                    EditorGUILayout.LabelField("");
                    inputNode.stateRef.onExitList.DoLayoutList();
                    standard +=
                        100 + 40 + (inputNode.stateRef.onEnterList.count + inputNode.stateRef.onExitList.count) * 20;
                }

                inputNode.stateRef.serializedState.ApplyModifiedProperties();
                inputNode.windowRect.height = standard;
            }
            else
            {
                inputNode.isAssigned = false;
            }
        }
Exemplo n.º 3
0
        public override void DrawCurve(Node inputNode)
        {
            var inputNodeRect = inputNode.windowRect;

            inputNodeRect.y     += inputNode.windowRect.height * .5f;
            inputNodeRect.width  = 1;
            inputNodeRect.height = 1;

            var fromNode = BrixEditor.Settings.currentGraph.GetNodeById(inputNode.transitionInputNode);

            if (fromNode == null)
            {
                BrixEditor.Settings.currentGraph.MarkNodeForDeletion(inputNode.id);
            }
            else
            {
                var targetColor = Color.green;
                if (!inputNode.isAssigned || inputNode.isDuplicate)
                {
                    targetColor = Color.red;
                }

                var fromRect = fromNode.windowRect;
                BrixEditor.DrawNodeCurve(fromRect, inputNodeRect, true, targetColor);
            }

            if (inputNode.isDuplicate)
            {
                return;
            }

            if (inputNode.transitionTargetNode > 0)
            {
                var targetNode = BrixEditor.Settings.currentGraph.GetNodeById(inputNode.transitionTargetNode);
                if (targetNode == null)
                {
                    inputNode.transitionTargetNode = -1;
                }
                else
                {
                    inputNodeRect    = inputNode.windowRect;
                    inputNodeRect.x += inputNodeRect.width;
                    var targetRect = targetNode.windowRect;
                    targetRect.x -= targetRect.width * .5f;

                    var targetColor = Color.green;
                    if (targetNode.drawNode is StateNode)
                    {
                        if (!targetNode.isAssigned || targetNode.isDuplicate)
                        {
                            targetColor = Color.red;
                        }
                    }
                    else
                    {
                        targetColor = targetNode.isAssigned ? Color.yellow : Color.red;
                    }

                    BrixEditor.DrawNodeCurve(inputNodeRect, targetRect, false, targetColor);
                }
            }
        }