示例#1
0
 /// <summary>
 /// Initializes the dialog editor.
 /// </summary>
 private void Awake() // Like a constructor. Called at start
 {
     GraphEditor            = new WireGraphEditor(this);
     clickManager           = new ClickManager(this);
     ConnectionMaker        = new ConnectionMaker(this);
     TransformationsManager = new TransformationsManager(this);
     Background             = new Background();
     ContextMenu            = new DialogContextMenu(this);
     GUIScaleUtility.Init();
 }
示例#2
0
        /// <summary>
        /// Called every time the editor updates the editor UI. All the drawing logic is here.
        /// </summary>
        private void OnGUI()
        {
            try
            {
                if (Instance == null)
                {
                    Close();
                    return;
                }

                // Absolutely close the window BEFORE entering the play mode, or the dialog could be lost due to the nature of the Unity serialization.
                if (EditorApplication.isPlaying || EditorApplication.isCompiling || EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    Close();
                    return;
                }

                // First, get the user interaction data
                Event currentEvent = Event.current;
                TransformationsManager.ManagePan(currentEvent);
                TransformationsManager.ManageZoom(currentEvent);
                clickManager.ManageClick();

                // Then draw the background first
                Background.Draw(position, ref backgroundTexture, TransformationsManager.State.PanOffset);

                // If the connection is making a connection (but not finished), the draw the curve between the selected output and the cursor
                if (ConnectionMaker.MakingConnection)
                {
                    ConnectionMaker.DrawMouseCurve();
                }
                // Then draw the nodes
                GraphEditor.Draw();

                // And finally draw the toolbar
                DrawToolbar();
            }
            catch (Exception)
            {
                Debug.Log("An error occurred in the Dialog Editor. Please try to restart it.");
                Close();
            }
        }