示例#1
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
                                           string[] movedFromAssetPaths)
        {
            var vseWindows = (VseWindow[])Resources.FindObjectsOfTypeAll(typeof(VseWindow));

            if (deletedAssets.Any())
            {
                foreach (var deleted in deletedAssets)
                {
                    if (Instance.m_ProjectAssetPaths.Contains(deleted))
                    {
                        foreach (var vseWindow in vseWindows)
                        {
                            vseWindow.UnloadGraphIfDeleted();
                        }

                        // TODO : Fix for 1st drop. Find a better solution
                        var graphName = Path.GetFileNameWithoutExtension(deleted);
                        if (!string.IsNullOrEmpty(graphName))
                        {
                            var path = Path.Combine(ModelUtility.GetAssemblyRelativePath(), graphName + ".cs");
                            AssetDatabase.DeleteAsset(path);
                        }
                    }
                }
            }

            if (movedAssets.Any())
            {
                for (var i = 0; i < movedAssets.Length; ++i)
                {
                    var newAsset = movedAssets[i];
                    var oldAsset = movedFromAssetPaths[i];

                    if (Instance.m_ProjectAssetPaths.Contains(oldAsset))
                    {
                        foreach (var vseWindow in vseWindows)
                        {
                            vseWindow.UnloadGraphIfDeleted();
                        }

                        // TODO : Fix for 1st drop. Find a better solution
                        var newGraphName = Path.GetFileNameWithoutExtension(newAsset);
                        var oldGraphName = Path.GetFileNameWithoutExtension(oldAsset);

                        // if the Graph has been renamed, not just moved
                        if (!string.IsNullOrEmpty(newGraphName) && newGraphName != oldGraphName)
                        {
                            var path = Path.Combine(ModelUtility.GetAssemblyRelativePath(), oldGraphName + ".cs");
                            AssetDatabase.DeleteAsset(path);
                            var newAssetModel = AssetDatabase.LoadAssetAtPath <VSGraphAssetModel>(newAsset);
                            newAssetModel.name = newGraphName;
                            ((VSGraphModel)newAssetModel.GraphModel).name = newGraphName;
                            foreach (var vseWindow in vseWindows.Where(w => w.CurrentGraphModel == newAssetModel.GraphModel))
                            {
                                vseWindow.Store.Dispatch(new RefreshUIAction(UpdateFlags.All));
                            }
                        }
                    }
                }
            }

            var importedGraphAssets = importedAssets.Where(AssetAtPathIsVsGraphAsset).ToList();

            Instance.m_ProjectAssetPaths.AddRange(importedGraphAssets);
            if (importedGraphAssets.Any())
            {
                Version++;
            }
        }
 public override string GetSourceFilePath(VSGraphModel graphModel)
 {
     return(Path.Combine(ModelUtility.GetAssemblyRelativePath(), graphModel.TypeName + ".asset"));
 }
 public virtual string GetSourceFilePath(VSGraphModel graphModel)
 {
     return(Path.Combine(ModelUtility.GetAssemblyRelativePath(), graphModel.TypeName + ".cs"));
 }