Beispiel #1
0
        public INodeModel CreateStackedNode(Type nodeTypeToCreate, string nodeName = "", int index = -1, SpawnFlags spawnFlags = SpawnFlags.Default, Action <NodeModel> preDefineSetup = null, GUID?guid = null)
        {
            SpawnFlags createNodeFlags = (spawnFlags & SpawnFlags.CreateNodeAsset) | SpawnFlags.Orphan; // we don't want to CreateNode to add the node to the graph nor to register undo
            var        graphModel      = (GraphModel)GraphModel;
            NodeModel  nodeModel       = (NodeModel)graphModel.CreateNodeInternal(nodeTypeToCreate, nodeName, Vector2.zero, createNodeFlags, preDefineSetup, guid);

            graphModel.RegisterNodeGuid(nodeModel);
            if (!spawnFlags.IsOrphan())
            {
                if (spawnFlags.IsUndoable())
                {
                    AddStackedNode(nodeModel, index);
                    AssetModel.SetAssetDirty();
                }
                else
                {
                    AddStackedNode(nodeModel, index);
                }
            }
            nodeModel.DefineNode();

            return(nodeModel);
        }