示例#1
0
        /// <summary>
        /// Initialize the window from a character.
        /// </summary>
        private void InitializeFromCharacter()
        {
            mNodes       = new List <NodeGraphWindowBaseNode>();
            mConnections = new List <NodeGraphWindowBaseConnection>();

            mCachedDialogAsset = kEditingDialog;
            if (mCachedDialogAsset == null)
            {
                return;
            }

            var nodes = mCachedDialogAsset.GetNodes_Editor();

            foreach (BaseNode n in nodes)
            {
                mNodes.Add(new NodeGraphWindowBaseNode(n, GenerateNodeStyle(n.GetType()), OnRemoveNode, OnTryAddConnection));
            }

            var conns = mCachedDialogAsset.GetConnections_Editor();

            foreach (BaseConnection c in conns)
            {
                mConnections.Add(new NodeGraphWindowBaseConnection(c, OnRemoveConnection));
            }
        }
示例#2
0
        /// <summary>
        /// Draw the background and the nodes and then process events.
        /// </summary>
        private void OnGUI()
        {
            DrawBackground();
            DrawGrid(12.0f, Color.white * 0.420f);
            DrawGrid(120.0f, Color.white * 0.29f);

            if (mCachedDialogAsset == null)
            {
                return;
            }

            if (mCachedDialogAsset != kEditingDialog || mCachedDialogAsset.GetNodes_Editor().Count != mNodes.Count)
            {
                InitializeFromCharacter();
            }

            Matrix4x4 pop = GUI.matrix;

            GUI.matrix = Matrix4x4.TRS(mDragDelta, Quaternion.identity, Vector3.one) * pop;

            DrawConnections();
            DrawNodes();

            ProcessConnectionEvents(Event.current);
            ProcessNodeEvents(Event.current);
            ProcessEvents(Event.current);

            if (GUI.changed)
            {
                Repaint();
            }

            GUI.matrix = pop;
        }