Exemplo n.º 1
0
        public void OnClickRemoveNode(SDFNode node)
        {
            if (_graph.connections != null)
            {
                List <Connection> connectionsToRemove = new List <Connection>();

                foreach (var connection in _graph.connections)
                {
                    if (node.inPoints.Any(x => x.GetNode() == connection.outPoint.GetNode()) ||
                        node.outPoints.Any(x => x.GetNode() == connection.inPoint.GetNode()))
                    {
                        connectionsToRemove.Add(connection);
                    }
                }

                foreach (var conToRemove in connectionsToRemove)
                {
                    _graph.connections.Remove(conToRemove);
                }

                connectionsToRemove = null;
            }
            _graph.nodes.Remove(node);
            DestroyImmediate(node, true);
            AssetDatabase.SaveAssets();
        }
Exemplo n.º 2
0
        //only Used for newly created connection points
        public void Init(SDFNode node, ConnectionPointType type)
        {
            this.node = node;
            this.type = type;

            id = Guid.NewGuid().ToString();
            Init();
        }
Exemplo n.º 3
0
        public void OnClickAddNode <T>(Vector2 mousePosition) where T : SDFNode
        {
            if (_graph.nodes == null)
            {
                _graph.nodes = new List <SDFNode>();
            }

            SDFNode newNode = CreateInstance <T>();

            newNode.Setup(mousePosition, _graph);

            AssetDatabase.AddObjectToAsset(newNode, _graph);
            AssetDatabase.SaveAssets();
            _graph.nodes.Add(newNode);
        }
Exemplo n.º 4
0
 public virtual void OnAfterDeserialize(SDFNode node)
 {
     this.node = node;
     node.graph.connectionPointMapping.Add(id, this);
     Init();
 }