示例#1
0
        public BaseGraphView(EditorWindow window)
        {
            serializeGraphElements = SerializeGraphElementsCallback;
            canPasteSerializedData = CanPasteSerializedDataCallback;
            unserializeAndPaste    = UnserializeAndPasteCallback;
            graphViewChanged       = GraphViewChangedCallback;
            viewTransformChanged   = ViewTransformChangedCallback;
            elementResized         = ElementResizedCallback;

            RegisterCallback <KeyDownEvent>(KeyDownCallback);
            RegisterCallback <DragPerformEvent>(DragPerformedCallback);
            RegisterCallback <DragUpdatedEvent>(DragUpdatedCallback);
            RegisterCallback <MouseDownEvent>(MouseDownCallback);
            RegisterCallback <MouseUpEvent>(MouseUpCallback);

            InitializeManipulators();

            SetupZoom(0.05f, 2f);

            Undo.undoRedoPerformed += ReloadView;

            createNodeMenu = ScriptableObject.CreateInstance <CreateNodeMenuWindow>();
            createNodeMenu.Initialize(this, window);

            if (nodeInspector == null)
            {
                nodeInspector = CreateNodeInspectorObject();
            }

            this.StretchToParentSize();
        }
示例#2
0
        public BaseGraphView(EditorWindow window)
        {
            serializeGraphElements = SerializeGraphElementsCallback;
            canPasteSerializedData = CanPasteSerializedDataCallback;
            unserializeAndPaste    = UnserializeAndPasteCallback;
            graphViewChanged       = GraphViewChangedCallback;
            viewTransformChanged   = ViewTransformChangedCallback;
            elementResized         = ElementResizedCallback;
            editorWindow           = window;

            RegisterCallback <KeyDownEvent>(KeyDownCallback);
            RegisterCallback <DragPerformEvent>(DragPerformedCallback);
            RegisterCallback <DragUpdatedEvent>(DragUpdatedCallback);
            RegisterCallback <MouseDownEvent>(MouseDownCallback);
            RegisterCallback <MouseMoveEvent>(MouseMoveCallback);
            RegisterCallback <WheelEvent>(ZoomCallback);

            InitializeManipulators();

            SetupZoom(0.25f, 2.5f);

            Undo.undoRedoPerformed += ReloadView;

            createNodeMenu = ScriptableObject.CreateInstance <CreateNodeMenuWindow>();
            createNodeMenu.Initialize(this, editorWindow);

            this.StretchToParentSize();
            initialized += () => ZoomCallback(new WheelEvent());
        }
        void ShowNodeCreationMenuFromEdge(EdgeView edgeView, Vector2 position)
        {
            if (edgeNodeCreateMenuWindow == null)
            {
                edgeNodeCreateMenuWindow = ScriptableObject.CreateInstance <CreateNodeMenuWindow>();
            }

            edgeNodeCreateMenuWindow.Initialize(graphView, EditorWindow.focusedWindow, edgeView);
            SearchWindow.Open(new SearchWindowContext(position + EditorWindow.focusedWindow.position.position), edgeNodeCreateMenuWindow);
        }