public void Initialize(ScenimaticScript newScript)
        {
            refreshConnections = new List <ConnectionPoint>();
            connectionPoints   = new Dictionary <string, ConnectionPoint>();
            script             = newScript;

            CreateBranchEditorWindow();

            zoomerSettings            = new ZoomerSettings();
            zoomerSettings.zoomOrigin = script.zoomOrigin;
            zoomerSettings.zoomScale  = script.zoomScale > ZoomWindow.MIN_ZOOM ? script.zoomScale : 1;

            if (!string.IsNullOrEmpty(script.spriteAtlas))
            {
                string[] matches = AssetDatabase.FindAssets(script.spriteAtlas);
                foreach (var match in matches)
                {
                    string path = AssetDatabase.GUIDToAssetPath(match);

                    if (Path.GetExtension(path) != ".spriteatlas")
                    {
                        Debug.Log(path + " not a spriteatlas");
                    }
                    else
                    {
                        spriteAtlas = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(path);
                        break;
                    }
                }
            }

            ConnectionPoint.nodeGraph = this;

            inputNode         = new ScriptGatewayNodeData(this, newScript.inputNode);
            outputNode        = new ScriptGatewayNodeData(this, newScript.outputNode);
            branchEntityDatas = new List <GraphEntityData>();
            for (int i = 0; i < script.branches.Count; ++i)
            {
                ScenimaticSerializedNode branchData = script.branches[i];
                EventBranchObjectData    node       = new EventBranchObjectData(branchData, this);
                branchEntityDatas.Add(node);
            }


            if (script.lastSelectedNode < 0 || script.lastSelectedNode >= branchEntityDatas.Count)
            {
                SelectEntity(inputNode);
            }
            else
            {
                SelectEntity(branchEntityDatas[script.lastSelectedNode]);
            }
        }
        public void MouseOver(GraphEntityData graphEntityData)
        {
            // Left mouse up over this entity
            if (startConnection == null)
            {
                return;
            }

            if (startConnection.data.type != ConnectionType.ControlFlow &&
                graphEntityData != startConnection.nodeWindow.entityData)
            {
                ScriptGatewayNodeData gatewayData     = graphEntityData as ScriptGatewayNodeData;
                ScriptGatewayNodeData connGatewayData = startConnection.nodeWindow.entityData as ScriptGatewayNodeData;
                if (gatewayData == null && connGatewayData == null)
                {
                    if (startConnection.connectionDirection == ConnectionPointDirection.Out)
                    {
                        CreateNewConnectionPointContextMenu(graphEntityData, startConnection);
                    }
                }
                else
                {
                    if ((connGatewayData != null &&
                         (connGatewayData.serializedNode.data.gatewayType == GatewayType.Entrance ||
                          gatewayData != null)) ||
                        (gatewayData != null && gatewayData.serializedNode.data.gatewayType == GatewayType.Entrance) ||
                        (gatewayData != null && gatewayData.serializedNode.data.gatewayType == GatewayType.Exit &&
                         startConnection.connectionDirection != ConnectionPointDirection.In))
                    {
                        CreateNewConnectionPointContextMenu(graphEntityData, startConnection);
                    }
                }
            }

            startConnection.isCreatingNewConnection = false;
            startConnection = null;
        }