상속: UnityEditor.Experimental.GraphView.Node
예제 #1
0
        public static NoduxGraphNodeView Load(
            SerializedNoduxLinkGraph serializedObject,
            GraphNodeData inspectorNode,
            int index
            )
        {
            var nodeView = new NoduxGraphNodeView()
            {
                title = inspectorNode.Name,
                name  = inspectorNode.Name,
                Data  = inspectorNode.Node,
                Guid  = inspectorNode.Guid
            };

            var inputPort  = GenerateInputPort(nodeView);
            var outputPort = GenerateOutputPort(nodeView);

            var property = serializedObject.GetNode(index);

            INodeFieldRenderer.Render(nodeView.extensionContainer, property, inspectorNode.Node);

            nodeView.styleSheets.Add(Resources.Load <StyleSheet>("NoduxGraphNode"));
            nodeView.RefreshPorts();
            nodeView.RefreshExpandedState();
            nodeView.SetPosition(new Rect(inspectorNode.Position, DefaultNodeSize));
            return(nodeView);
        }
예제 #2
0
        public static void LinkNode(GraphView view, NoduxGraphNodeView source, NoduxGraphNodeView target)
        {
            var sourcePort = source.outputContainer.Q <Port>();
            var targetPort = target.inputContainer.Q <Port>();

            LinkPort(view, sourcePort, targetPort);
        }
예제 #3
0
        public static NoduxGraphNodeView Create(
            SerializedNoduxLinkGraph serializedObject,
            INode nodeData,
            Vector2 position)
        {
            var type          = nodeData.GetType();
            var name          = type.Name;
            var inspectorNode = new GraphNodeData()
            {
                Guid     = Guid.NewGuid().ToString(),
                Name     = name,
                Position = position,
                Node     = nodeData,
            };

            var nodeView = new NoduxGraphNodeView()
            {
                title = inspectorNode.Name,
                name  = inspectorNode.Name,
                Data  = inspectorNode.Node,
                Guid  = inspectorNode.Guid
            };

            var inputPort  = GenerateInputPort(nodeView);
            var outputPort = GenerateOutputPort(nodeView);

            var index    = serializedObject.AddNode(inspectorNode);
            var property = serializedObject.GetNode(index);

            INodeFieldRenderer.Render(nodeView.extensionContainer, property, inspectorNode.Node);

            nodeView.styleSheets.Add(Resources.Load <StyleSheet>("NoduxGraphNode"));
            nodeView.RefreshPorts();
            nodeView.RefreshExpandedState();
            nodeView.SetPosition(new Rect(inspectorNode.Position, DefaultNodeSize));
            return(nodeView);
        }