Пример #1
0
        static State CreateGraphAsset(State previousState, CreateGraphAssetAction action)
        {
            previousState.AssetModel?.Dispose();
            using (new AssetWatcher.Scope())
            {
                GraphAssetModel graphAssetModel = GraphAssetModel.Create(action.Name, action.AssetPath, action.AssetType, action.WriteOnDisk);

                var graphModel = graphAssetModel.CreateGraph <VSGraphModel>(action.Name, action.GraphType, action.WriteOnDisk);
                if (action.GraphTemplate != null)
                {
                    action.GraphTemplate.InitBasicGraph(graphModel);
                    previousState.requestNodeAlignment = true;
                }

                previousState.AssetModel = graphAssetModel;
                if (action.Instance)
                {
                    previousState.EditorDataModel.BoundObject = action.Instance;
                }
            }
            if (action.WriteOnDisk)
            {
                AssetDatabase.SaveAssets();
            }

            previousState.MarkForUpdate(UpdateFlags.All);

            return(previousState);
        }
        static State CreateGraphAsset(State previousState, CreateGraphAssetAction action)
        {
            previousState.AssetModel?.Dispose();
            using (new AssetWatcher.Scope())
            {
                GraphAssetModel graphAssetModel = GraphAssetModel.Create(action.Name, action.AssetPath, action.AssetType, action.WriteOnDisk);

                var graphModel = graphAssetModel.CreateGraph(action.GraphType, action.Name, action.StencilType, action.WriteOnDisk);
                if (action.GraphTemplate != null)
                {
                    action.GraphTemplate.InitBasicGraph(graphModel as VSGraphModel);
                    graphModel.LastChanges.ModelsToAutoAlign.AddRange(graphModel.Stencil.GetEntryPoints((VSGraphModel)graphModel));
                }

                previousState.AssetModel = graphAssetModel;
                if (action.Instance)
                {
                    previousState.EditorDataModel.BoundObject = action.Instance;
                }
            }
            if (action.WriteOnDisk)
            {
                AssetDatabase.SaveAssets();
            }

            AssetWatcher.Instance.WatchGraphAssetAtPath(action.AssetPath, (GraphAssetModel)previousState.AssetModel);
            previousState.MarkForUpdate(UpdateFlags.All);


            return(previousState);
        }