示例#1
0
 public void RenameFilterOutputPointLabel(int changedIndex, string latestLabel)
 {
     outputConnectionPoints[changedIndex].label = latestLabel;
     NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, this, Vector2.zero, outputConnectionPoints[changedIndex].pointId));
     Save();
     UpdateNodeRect();
 }
示例#2
0
        /**
         *      node's setting is changed from Inspector.
         */
        public void Save()
        {
            /*
             *      update as no errors.
             */
            RenewErrorSource();

            NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_SAVE, this, Vector2.zero, null));
        }
示例#3
0
        public void DeleteFilterOutputPoint(int deletedIndex)
        {
            var deletedConnectionPoint = outputConnectionPoints[deletedIndex];

            NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, this, Vector2.zero, deletedConnectionPoint.pointId));
            outputConnectionPoints.Remove(deletedConnectionPoint);
            Save();
            UpdateNodeRect();
        }
示例#4
0
 public void RenameInputPoint(string guid, string label)
 {
     inputConnectionPoints.ForEach(c => { if (c.pointId == guid)
                                          {
                                              c.label = label;
                                              NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, this, Vector2.zero, c.pointId));
                                          }
                                   });
     Save();
     UpdateNodeRect();
 }
示例#5
0
        public void DeleteInputPoint(string guid)
        {
            int deletedIndex = inputConnectionPoints.FindIndex(c => c.pointId == guid);

            if (deletedIndex >= 0)
            {
                NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, this, Vector2.zero, guid));
                inputConnectionPoints.RemoveAt(deletedIndex);
                Save();
                UpdateNodeRect();
            }
        }
示例#6
0
        public void DrawConnectionOutputPointMark(OnNodeEvent eventSource, bool justConnecting, Event current)
        {
            if (scaleFactor != SCALE_MAX)
            {
                return;
            }

            var defaultPointTex = NodeGUIUtility.outputPointMarkConnectedTex;

            if (justConnecting && eventSource != null)
            {
                if (eventSource.eventSourceNode.nodeId != this.nodeId)
                {
                    var connectionPoint = eventSource.eventSourceNode.ConnectionPointFromConPointId(eventSource.conPointId);
                    if (connectionPoint.isInput)
                    {
                        defaultPointTex = NodeGUIUtility.enablePointMarkTex;
                    }
                }
            }

            var globalMousePosition = current.mousePosition;

            var connectionPoints = WholeConnectionPoints();

            foreach (var point in connectionPoints)
            {
                if (point.isOutput)
                {
                    var outputPointRect = GetOutputRectForPoint(point);

                    GUI.DrawTexture(
                        outputPointRect,
                        defaultPointTex
                        );

                    // eventPosition is contained by outputPointRect.
                    if (outputPointRect.Contains(globalMousePosition))
                    {
                        if (current.type == EventType.MouseDown)
                        {
                            NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_NODE_CONNECT_STARTED, this, current.mousePosition, point.pointId));
                        }
                    }
                }
            }
        }
示例#7
0
        /**
         *      retrieve mouse events for this node in this AssetGraoh window.
         */
        private void HandleNodeEvent()
        {
            switch (Event.current.type)
            {
            /*
             *      handling release of mouse drag from this node to another node.
             *      this node doesn't know about where the other node is. the master only knows.
             *      only emit event.
             */
            case EventType.Ignore: {
                NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_NODE_CONNECTION_OVERED, this, Event.current.mousePosition, null));
                break;
            }

            /*
             *      handling drag.
             */
            case EventType.MouseDrag: {
                NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_NODE_MOVING, this, Event.current.mousePosition, null));
                break;
            }

            /*
             *      check if the mouse-down point is over one of the connectionPoint in this node.
             *      then emit event.
             */
            case EventType.MouseDown: {
                var connectionPoints = WholeConnectionPoints();
                var result           = IsOverConnectionPoint(connectionPoints, Event.current.mousePosition);

                if (!string.IsNullOrEmpty(result))
                {
                    if (scaleFactor == SCALE_MAX)
                    {
                        NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_NODE_CONNECT_STARTED, this, Event.current.mousePosition, result));
                    }
                    break;
                }
                break;
            }
            }

            /*
             *      retrieve mouse events for this node in|out of this AssetGraoh window.
             */
            switch (Event.current.rawType)
            {
            case EventType.MouseUp: {
                var connectionPoints = WholeConnectionPoints();
                // if mouse position is on the connection point, emit mouse raised event.
                foreach (var connectionPoint in connectionPoints)
                {
                    var globalConnectonPointRect = new Rect(connectionPoint.buttonRect.x, connectionPoint.buttonRect.y, connectionPoint.buttonRect.width, connectionPoint.buttonRect.height);
                    if (globalConnectonPointRect.Contains(Event.current.mousePosition))
                    {
                        NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_NODE_CONNECTION_RAISED, this, Event.current.mousePosition, connectionPoint.pointId));
                        return;
                    }
                }

                NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_NODE_TOUCHED, this, Event.current.mousePosition, null));
                break;
            }
            }

            /*
             *      right click to open Context menu
             */
            if (scaleFactor == SCALE_MAX)
            {
                if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(
                        new GUIContent("Delete"),
                        false,
                        () => {
                        NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_CLOSE_TAPPED, this, Vector2.zero, null));
                    }
                        );
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }
        }
示例#8
0
 public void BeforeSave()
 {
     NodeGUIUtility.FireNodeEvent(new OnNodeEvent(OnNodeEvent.EventType.EVENT_BEFORESAVE, this, Vector2.zero, null));
 }