Exemple #1
0
        protected override void OnGUI()
        {
            mainToolbar.OnGUI();
            EventType eventType = FsmEditorUtility.ReserveEvent(variableEditorRect, fsmSelectionRect, preferencesRect);

            ZoomableArea.Begin(new Rect(0f, 0f, scaledCanvasSize.width, scaledCanvasSize.height + 21), scale, IsDocked);
            Begin();

            shortcutEditor.HandleKeyEvents();
            if (FsmEditor.Active != null)
            {
                DoNodes();
            }
            else
            {
                ZoomableArea.End();
            }
            AcceptDragAndDrop();
            End();

            FsmEditorUtility.ReleaseEvent(eventType);
            PreferencesEditor.DoGUI(preferencesRect);
            shortcutEditor.DoGUI(shortcutRect);
            DoFsmSelection(fsmSelectionRect);
            variableEditor.DoGUI(variableEditorRect);
            if (centerView)
            {
                CenterView();
                centerView = false;
            }
            if (FsmEditor.Active != null)
            {
                GUI.Label(new Rect(5, 20, 300, 200), FsmEditor.Active.comment, FsmEditorStyles.instructionLabel);
            }
            else
            {
                GUI.Label(new Rect(5, 20, 300, 200), "Right click to create a state machine.", FsmEditorStyles.instructionLabel);
            }
            Event ev = Event.current;

            if (SelectedNodes.Count == 1 && ev.rawType == EventType.KeyDown && ev.keyCode == KeyCode.Delete && FsmEditor.SelectedTransition != null && EditorUtility.DisplayDialog("Delete selected transition?", FsmEditor.SelectedTransition.FromNode.Name + " -> " + FsmEditor.SelectedTransition.ToNode.Name + "\r\n\r\nYou cannot undo this action.", "Delete", "Cancel"))
            {
                Node node = SelectedTransition.FromNode;
                node.Transitions = ArrayUtility.Remove(node.Transitions, FsmEditor.SelectedTransition);
                FsmEditorUtility.DestroyImmediate(FsmEditor.SelectedTransition);
                ErrorChecker.CheckForErrors();
                EditorUtility.SetDirty(node);
            }
        }
Exemple #2
0
		private void DoNodes(){
			DoTransitions ();
			for(int i=0;i< Nodes.Length;i++){
				Node node=Nodes[i];
				if(!selection.Contains(node)){
					DoNode(node);			
				}
			}

			for(int i=0;i< selection.Count;i++){
				Node node=selection[i];
				DoNode(node);			
			}

			DoNodeEvents ();
			ZoomableArea.End ();
			NodeContextMenu ();
		}