Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }