void Load(BuildTarget target, Model.NodeData node, IEnumerable <Model.ConnectionData> connectionsToOutput, PerformGraph.Output Output) { if (connectionsToOutput == null || Output == null) { return; } var outputSource = new List <AssetReference>(); var loadPath = GetLoadPath(target); var targetFiles = AssetDatabase.FindAssets("", new string[] { loadPath }); foreach (var assetGuid in targetFiles) { var targetFilePath = AssetDatabase.GUIDToAssetPath(assetGuid); if (!TypeUtility.IsLoadingAsset(targetFilePath)) { continue; } // Skip folders var type = TypeUtility.GetMainAssetTypeAtPath(targetFilePath); if (type == typeof(UnityEditor.DefaultAsset) && AssetDatabase.IsValidFolder(targetFilePath)) { continue; } var r = AssetReferenceDatabase.GetReference(targetFilePath); if (r == null) { continue; } if (outputSource.Contains(r)) { continue; } if (IsIgnored(targetFilePath)) { continue; } outputSource.Add(r); } var output = new Dictionary <string, List <AssetReference> > { { "0", outputSource } }; var dst = (connectionsToOutput == null || !connectionsToOutput.Any())? null : connectionsToOutput.First(); Output(dst, output); }
public Dictionary <string, List <AssetReference> > ToGroupDictionary() { Dictionary <string, List <AssetReference> > dic = new Dictionary <string, List <AssetReference> >(); foreach (var g in m_groups) { dic [g.name] = g.assets.Select(a => AssetReferenceDatabase.GetReference(a)).ToList(); } return(dic); }
void Load(BuildTarget target, Model.NodeData node, IEnumerable <Model.ConnectionData> connectionsToOutput, PerformGraph.Output Output) { if (connectionsToOutput == null || Output == null) { return; } var cond = m_searchFilter[target]; var outputSource = new List <AssetReference>(); var guids = AssetDatabase.FindAssets(cond); foreach (var guid in guids) { var targetFilePath = AssetDatabase.GUIDToAssetPath(guid); if (!TypeUtility.IsLoadingAsset(targetFilePath)) { continue; } var r = AssetReferenceDatabase.GetReference(targetFilePath); if (r != null) { outputSource.Add(AssetReferenceDatabase.GetReference(targetFilePath)); } } var output = new Dictionary <string, List <AssetReference> > { { "0", outputSource } }; var dst = (connectionsToOutput == null || !connectionsToOutput.Any())? null : connectionsToOutput.First(); Output(dst, output); }
private void HandleAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int i = 0; i < movedFromAssetPaths.Length; i++) { if (movedFromAssetPaths[i] == DataModel.Version2.Settings.Path.BasePath) { DataModel.Version2.Settings.Path.ResetBasePath(movedAssets[i]); } } foreach (string str in importedAssets) { AssetReferenceDatabase.GetReference(str).InvalidateTypeCache(); } foreach (string str in deletedAssets) { AssetReferenceDatabase.DeleteReference(str); } for (int i = 0; i < movedAssets.Length; i++) { AssetReferenceDatabase.MoveReference(movedFromAssetPaths[i], movedAssets[i]); } var ctx = new AssetPostprocessorContext(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths, m_contexts); if (!ctx.HasValidAssetToPostprocess()) { return; } // if modification happens inside graph, record it. if (m_controllers.Count > 0) { m_ppQueue.Enqueue(ctx); return; } DoPostprocessWithContext(ctx); }
public void Init(Stack <AssetPostprocessorContext> ctxStack) { m_importedAssets = new List <AssetReference>(); m_movedAssets = new List <AssetReference>(); foreach (var path in m_importedAssetPaths) { if (!TypeUtility.IsLoadingAsset(path)) { continue; } bool isAssetFoundInStack = false; foreach (var ctx in ctxStack) { if (ArrayUtility.Contains(ctx.ImportedAssetPaths, path) || ctx.ImportedAssets.Find(a => a.importFrom == path) != null) { isAssetFoundInStack = true; break; } } if (!isAssetFoundInStack) { var a = AssetReferenceDatabase.GetReference(path); m_importedAssets.Add(a); } } for (int i = 0; i < m_movedAssetPaths.Length; ++i) { var movedTo = m_movedAssetPaths [i]; if (!TypeUtility.IsLoadingAsset(movedTo)) { continue; } var a = AssetReferenceDatabase.GetReference(movedTo); m_movedAssets.Add(a); } }