static List <string> GuidOfUsersFallback(string dependencyGuid) { var dependencyPath = AssetDatabase.GUIDToAssetPath(dependencyGuid); List <string> users = new List <string>(); var allFiles = Directory.EnumerateFiles("Assets", "*", SearchOption.AllDirectories); var disabledExtensions = new List <string>() { ".meta", ".cs", ".txt", ".png", ".ogg" }; var assets = allFiles.Where(s => !disabledExtensions.Contains(Path.GetExtension(s))).ToList(); for (var index = 0; index < assets.Count; index++) { var asset = assets[index]; if (EditorUtility.DisplayCancelableProgressBar("Dependencies", asset, index / (float)assets.Count)) { break; } var dependencies = AssetDatabase.GetDependencies(asset, false); if (dependencies.Contains(dependencyPath)) { users.Add(AssetDatabase.GUIDFromAssetPath(asset).ToString()); } } EditorUtility.ClearProgressBar(); return(users); }
public override void OnImportAsset(AssetImportContext ctx) { var json = File.ReadAllText(ctx.assetPath); var asset = ScriptableObject.CreateInstance <ActionAsset>(); var settings = ProjectUtility.GetOrCreateProjectSettings <ActionGraphGlobalSettings>(); var jsonSettings = JsonConvert.DefaultSettings.Invoke(); jsonSettings.TypeNameHandling = TypeNameHandling.All; var model = JsonConvert.DeserializeObject <ActionAssetModel>(json, jsonSettings); if (model.id.IsCreated) { AssetDatabase.SetLabels(asset, new string[] { $"Action:{model.id.ToString()}" }); } asset.actionId = model.id; if (string.IsNullOrWhiteSpace(userData) || AssetDatabase.GUIDToAssetPath(userData) == null) { var artifactPath = settings.CreateArtifactPath(); AssetDatabase.CreateAsset(new TextAsset(), artifactPath); userData = AssetDatabase.GUIDFromAssetPath(artifactPath).ToString(); Debug.Log(artifactPath); Debug.Log(userData); } ctx.AddObjectToAsset("Action", asset, ActionAssetEditor.AssetIcon); ctx.SetMainObject(asset); }
public static void SetAddressableGroupAutomatically(Object obj) { var assetPath = AssetDatabase.GetAssetPath(obj); var parentPath = assetPath; while (string.IsNullOrEmpty(parentPath) == false) { var newParentPath = Path.GetDirectoryName(parentPath); if (newParentPath == parentPath) { break; } parentPath = newParentPath; var parentPathGuid = AssetDatabase.GUIDFromAssetPath(parentPath); if (AssetDatabase.GetLabels(parentPathGuid).Contains("AddressablesGroup")) { break; } } if (parentPath == assetPath) { Debug.LogWarning($"{assetPath}: Addressables Group cannot be determined from asset path."); } else { var parentDirName = Path.GetFileNameWithoutExtension(parentPath); SetAddressableGroup(obj, parentDirName); } }
public static string Write(this UIModel model) { var fi = new FileInfo(model.output); fi.Directory.Create(); using (var fs = fi.Create()) { Write(model, fs, UIGlobalSettings.GetOrCreateSettings().schema); } AssetDatabase.SaveAssets(); AssetDatabase.ImportAsset(model.output); AssetDatabase.Refresh(); //return AssetDatabase.GUIDFromAssetPath(model.output).ToString(); var settings = AddressableAssetSettingsDefaultObject.GetSettings(false); var guid = AssetDatabase.GUIDFromAssetPath(model.output).ToString(); if (settings != null && !string.IsNullOrEmpty(model.address)) { var entry = settings.FindAssetEntry(guid); if (entry == null) { entry = settings.CreateOrMoveEntry(guid, settings.FindGroup(UI_ADDRESSABLES_GROUP) ?? AddressableAssetSettingsDefaultObject.Settings.CreateGroup(UI_ADDRESSABLES_GROUP, false, false, false, null)); } entry.SetAddress(model.address); } return(guid); }
private static bool AssetExistsAtPath(string path) { var guidFromPath = AssetDatabase.GUIDFromAssetPath(path); // also testing for file existence to cover scenarios where the ADB did not import the asset yet return(!guidFromPath.Empty() || File.Exists(path)); }
private static void CreateVariant() { Object target = Selection.activeObject; if (!(target is ScriptableObject origin)) { return; } string text = "{}"; string path = Path.ChangeExtension(AssetDatabase.GetAssetPath(origin), null); string pathWithExtension; do { path = $"{path} (Variant)"; pathWithExtension = Path.ChangeExtension(path, extension); } while (File.Exists(pathWithExtension)); File.WriteAllText(pathWithExtension, text); AssetDatabase.ImportAsset(pathWithExtension, ImportAssetOptions.ForceSynchronousImport); VariantImporter assetImporter = (VariantImporter)GetAtPath(pathWithExtension); assetImporter.Origin = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(origin)).ToString(); EditorUtility.SetDirty(assetImporter); assetImporter.SaveAndReimport(); }
public static GUID PathToGUID(string assetPath) { #if UNITY_2020_2_OR_NEWER return(AssetDatabase.GUIDFromAssetPath(assetPath)); #else return(new GUID(AssetDatabase.AssetPathToGUID(assetPath))); #endif }
GetAssetForLabel(string path) { #if UNITY_2020_1_OR_NEWER return(AssetDatabase.GUIDFromAssetPath(path)); #else return(AssetDatabase.LoadAssetAtPath <GameObject>(path)); #endif }
private IndexArtifact[] CreateArtifacts(IList <string> assetPaths) { var artifacts = new IndexArtifact[assetPaths.Count]; for (int i = 0; i < assetPaths.Count; ++i) { artifacts[i] = new IndexArtifact(assetPaths[i], AssetDatabase.GUIDFromAssetPath(assetPaths[i])); } return(artifacts); }
private void OnEnable() { target = EditorUserBuildSettings.activeBuildTarget; assetGUID = EditorPrefs.GetString(assetGuidKey); if (assetGUID == "") { assetGUID = AssetDatabase.GUIDFromAssetPath("Assets/resources/benchmarksettings.asset").ToString(); } _benchConfigData = AssetDatabase.LoadAssetAtPath <BenchmarkConfigData>(AssetDatabase.GUIDToAssetPath(assetGUID)); }
public static void UpgradeMaterial(string path, Shader oldShader, Shader newShader) { Material material = AssetDatabase.LoadAssetAtPath <Material>(path); if (material.shader == oldShader) { material.shader = newShader; } GUID guid = AssetDatabase.GUIDFromAssetPath(path); AssetDatabase.SaveAssetIfDirty(guid); }
public void AssetDatabase_CreateFolder_AssetAsRoot() { RuntimeUrdf.runtimeModeEnabled = false; string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf"); string compareGUID = AssetDatabase.GUIDFromAssetPath(createFolderPath).ToString(); // Verify valid folder Assert.IsTrue(AssetDatabase.IsValidFolder(createFolderPath)); // Verify matching GUID Assert.AreEqual(createdGUID, compareGUID); // Try creating the same folder again createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf"); Assert.AreEqual(createdGUID, compareGUID); }
private static GUID GetIconGuid(ScriptableIcon icon) { var iconType = icon.Type; var iconPath = iconType switch { ScriptableIconType.Event => IconPathEvent, ScriptableIconType.Listener => IconPathListener, _ => string.Empty }; if (iconPath == string.Empty) { return(new GUID()); } return(AssetDatabase.GUIDFromAssetPath(iconPath)); }
public static string AssetDatabase_CreateFolder(string parentFolder, string newFolderName) { #if UNITY_EDITOR if (!IsRuntimeMode()) { if (!AssetDatabase.IsValidFolder($"{parentFolder}/{newFolderName}")) { return(AssetDatabase.CreateFolder(parentFolder, newFolderName)); } else { Debug.LogWarning($"{parentFolder}/{newFolderName} cannot be created! It may already exist."); return(AssetDatabase.GUIDFromAssetPath($"{parentFolder}/{newFolderName}").ToString()); } } #endif return(""); }
public override void Action(int instanceId, string pathName, string resourceFile) { var model = EditorUtility.InstanceIDToObject(instanceId) as BehaviourGraphModel; if (model != null) { model.outputFileName = GetName(pathName); AssetDatabase.CreateAsset(model, pathName); model.Settings.Models.Add(new BehaviourGraphSettings.ModelEntry { asset = AssetDatabase.GUIDFromAssetPath(pathName).ToString(), options = CompileOptions.All }); EditorUtility.SetDirty(model.Settings); EditorUtility.SetDirty(model); } }
private static string DoWriteArtifact <TAction>(string artifactFile, BlobAssetReference <ActionGraph <TAction> > blobAssetReference) where TAction : Delegate { using var writer = new StreamBinaryWriter(artifactFile); writer.Write(blobAssetReference); AssetDatabase.ImportAsset(artifactFile); #if ADDRESSABLES_EXISTS var guid = AssetDatabase.GUIDFromAssetPath(artifactFile).ToString(); if (AddressableAssetSettingsDefaultObject.SettingsExists) { var settings = AddressableAssetSettingsDefaultObject.Settings; if (settings != null) { var group = settings.DefaultGroup; var entry = settings.CreateOrMoveEntry(guid, group, true, true); } } return(guid); #else return(AssetDatabase.GUIDFromAssetPath(artifactFile).ToString()); #endif }
private void UpdateSettings(CompileOptions value) { if (serializedObject.targetObject is BehaviourGraphModel model) { var guid = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(model)).ToString(); var index = model.Settings.Models.FindIndex(m => m.asset == guid); var e = new BehaviourGraphSettings.ModelEntry { asset = guid, options = value }; if (index < 0) { model.Settings.Models.Add(e); } else { model.Settings.Models[index] = e; } } }
public void ProcessTemplateFile(string filePath) { if (File.Exists(filePath) && !includedFiles.Contains(filePath)) { includedFiles.Add(filePath); if (assetCollection != null) { GUID guid = AssetDatabase.GUIDFromAssetPath(filePath); if (!guid.Empty()) { assetCollection.AddAssetDependency(guid, AssetCollection.Flags.SourceDependency); } } string[] templateLines = File.ReadAllLines(filePath); foreach (string line in templateLines) { ProcessTemplateLine(line, 0, line.Length); } } }
/// <inheritdoc /> public override void OnImportAsset(AssetImportContext ctx) { if (ctx == null) { return; } var outputFilePath = Path.Combine(Path.GetDirectoryName(ctx.assetPath), Path.GetFileNameWithoutExtension(ctx.assetPath) + ".cs"); var src = File.ReadAllText(ctx.assetPath); TemplateGenerator generator; switch (importerVersion) { case ImporterVersion.Stable: generator = new TemplateGenerator(); break; case ImporterVersion.Beta: { generator = UnityDataHost <Object> .CreateInstance(embeddedData, additionalTypes); break; } default: throw new InvalidOperationException(); } if (generator.ProcessTemplate(ctx.assetPath, src, ref outputFilePath, out string dst)) { if (!removeIfEmptyGeneration || dst.Length > 0) { File.WriteAllText(outputFilePath, dst); } EditorUtils.Once(() => { // TODO(bengreenier): is there a less expensive way to force it to reload scripts/appdomain? AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); }); } else { for (var i = 0; i < generator.Errors.Count; i++) { var err = generator.Errors[i]; Debug.LogError(err.ToString()); } } // core asset import var asset = new TextAsset(src); ctx.AddObjectToAsset("text", asset); ctx.SetMainObject(asset); // setup data dependency if (embeddedData != null && importerVersion == ImporterVersion.Beta) { var dataPath = AssetDatabase.GetAssetPath(embeddedData); var dataGuid = AssetDatabase.GUIDFromAssetPath(dataPath); ctx.DependsOnArtifact(dataGuid); // needed to enforce the dependency AssetDatabase.LoadAssetAtPath <Object>(dataPath); } }
public override void OnImportAsset(AssetImportContext ctx) { var model = ScriptableObject.CreateInstance <UIModel>(); InitializeModel(model, new StringReader(File.ReadAllText(ctx.assetPath)), AssetDatabase.GUIDFromAssetPath(ctx.assetPath).ToString(), ctx.assetPath); model.Write(); ctx.AddObjectToAsset("UI Model", model); ctx.SetMainObject(model); }
public static string GetOutputGuid(this UIModel model) => AssetDatabase.GUIDFromAssetPath(model.output).ToString();
private static GUID GetIconGuid(string name) { return(AssetDatabase.GUIDFromAssetPath( $"{ScriptableEventConstants.PackagePath}/Editor/Textures/{name}.png" )); }
private static int GetAssetGuidHash(Object asset) { string assetPath = AssetDatabase.GetAssetPath(asset); return(AssetDatabase.GUIDFromAssetPath(assetPath).GetHashCode()); }
public void ModifiedProperty(string path, SerializedProperty property) { object data; switch (property.propertyType) { case SerializedPropertyType.Integer: case SerializedPropertyType.LayerMask: data = property.intValue; break; case SerializedPropertyType.Boolean: data = property.boolValue; break; case SerializedPropertyType.Float: data = property.floatValue; break; case SerializedPropertyType.String: case SerializedPropertyType.Character: data = property.stringValue; break; case SerializedPropertyType.Color: data = new Vector4Serializable(property.colorValue); break; case SerializedPropertyType.ObjectReference: data = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(property.objectReferenceValue)); break; case SerializedPropertyType.Enum: data = property.enumValueIndex; break; case SerializedPropertyType.Vector2: data = new Vector2Serializable(property.vector2Value); break; case SerializedPropertyType.Vector3: data = new Vector3Serializable(property.vector3Value); break; case SerializedPropertyType.Vector4: data = new Vector4Serializable(property.vector4Value); break; case SerializedPropertyType.Rect: data = new Vector4Serializable(property.rectValue); break; case SerializedPropertyType.ArraySize: data = property.arraySize; break; case SerializedPropertyType.AnimationCurve: data = new AnimationCurveSerializable(property.animationCurveValue); break; case SerializedPropertyType.Bounds: data = new BoundsSerializable(property.boundsValue); break; case SerializedPropertyType.Gradient: data = new GradientSerializable(GetGradientValue(property)); break; case SerializedPropertyType.Quaternion: data = new Vector4Serializable(property.quaternionValue); break; case SerializedPropertyType.Vector2Int: data = new Vector2Serializable(property.vector2IntValue); break; case SerializedPropertyType.Vector3Int: data = new Vector3Serializable(property.vector3IntValue); break; case SerializedPropertyType.RectInt: data = new Vector4Serializable(property.rectIntValue); break; case SerializedPropertyType.BoundsInt: data = new BoundsSerializable(property.boundsIntValue); break; case SerializedPropertyType.Hash128: data = property.hash128Value; break; case SerializedPropertyType.FixedBufferSize: // Although it may appear we can handle fixed buffer size, it cannot be deserialized. // data = property.fixedBufferSize; case SerializedPropertyType.ExposedReference: case SerializedPropertyType.Generic: case SerializedPropertyType.ManagedReference: default: Debug.LogWarning($"{property.propertyType} is not handled, sorry! ({property.propertyPath})"); return; } overrideData ??= new OverrideData(); overrideData.Overrides[path] = JToken.FromObject(data); serializedObject.FindProperty(nameof(VariantImporter.Json)).stringValue = JsonConvert.SerializeObject(overrideData); serializedObject.ApplyModifiedProperties(); }
public override void IndexDocument(string path, bool checkIfDocumentExists) { int assetInstanceId = Utils.GetMainAssetInstanceID(path); var globalObjectId = GlobalObjectId.GetGlobalObjectIdSlow(assetInstanceId); var documentIndex = AddDocument(globalObjectId.ToString(), null, path, checkIfDocumentExists, SearchDocumentFlags.Asset); if (documentIndex < 0) { return; } AddSourceDocument(path, GetDocumentHash(path)); IndexWordComponents(documentIndex, GetPartialPath(path)); var fileName = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); IndexWord(documentIndex, fileName, fileName.Length, true); IndexProperty(documentIndex, "name", fileName, saveKeyword: false); IndexWord(documentIndex, path, path.Length, exact: true); IndexProperty(documentIndex, "id", path, saveKeyword: false, exact: true); if (path.StartsWith("Packages/", StringComparison.Ordinal)) { IndexProperty(documentIndex, "a", "packages", saveKeyword: true, exact: true); } else { IndexProperty(documentIndex, "a", "assets", saveKeyword: true, exact: true); } var fi = new FileInfo(path); if (fi.Exists) { IndexNumber(documentIndex, "size", (double)fi.Length); IndexProperty(documentIndex, "ext", fi.Extension.Replace(".", "").ToLowerInvariant(), saveKeyword: false); IndexNumber(documentIndex, "age", (DateTime.Now - fi.LastWriteTime).TotalDays); foreach (var dir in Path.GetDirectoryName(path).Split(new[] { '/', '\\' }).Skip(1)) { IndexProperty(documentIndex, "dir", dir.ToLowerInvariant(), saveKeyword: false, exact: true); } IndexProperty(documentIndex, "t", "file", saveKeyword: true, exact: true); } else if (Directory.Exists(path)) { IndexProperty(documentIndex, "t", "folder", saveKeyword: true, exact: true); } var at = AssetDatabase.GetMainAssetTypeAtPath(path); var hasCustomIndexers = HasCustomIndexers(at); bool isPrefab = path.EndsWith(".prefab"); if (at != null) { IndexWord(documentIndex, at.Name); IndexTypes(at, documentIndex); if (settings.options.types) { foreach (var obj in AssetDatabase.LoadAllAssetRepresentationsAtPath(path).Where(o => o)) { IndexTypes(obj.GetType(), documentIndex); if (!AssetDatabase.IsSubAsset(obj)) { continue; } IndexSubAsset(obj, path, checkIfDocumentExists, hasCustomIndexers); } if (isPrefab) { var rootPrefabObject = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (rootPrefabObject) { var gocs = rootPrefabObject.GetComponents <Component>(); for (int componentIndex = 1; componentIndex < gocs.Length; ++componentIndex) { var c = gocs[componentIndex]; if (!c || (c.hideFlags & (HideFlags.DontSave | HideFlags.HideInInspector)) != 0) { continue; } IndexProperty(documentIndex, "t", c.GetType().Name, saveKeyword: true); } } } } } else if (at != null) { IndexProperty(documentIndex, "t", at.Name, saveKeyword: true); } var guid = AssetDatabase.GUIDFromAssetPath(path); var labels = AssetDatabase.GetLabels(guid); foreach (var label in labels) { IndexProperty(documentIndex, "l", label, saveKeyword: true); } if (settings.options.properties) { bool wasLoaded = AssetDatabase.IsMainAssetAtPathLoaded(path); var mainAsset = isPrefab ? PrefabUtility.LoadPrefabContents(path) : AssetDatabase.LoadMainAssetAtPath(path); if (!mainAsset) { return; } if (hasCustomIndexers) { IndexCustomProperties(path, documentIndex, mainAsset); } if (!string.IsNullOrEmpty(mainAsset.name)) { IndexWord(documentIndex, mainAsset.name, true); } if (settings.options.properties) { IndexObject(documentIndex, mainAsset, settings.options.dependencies); } if (mainAsset is GameObject go) { foreach (var v in go.GetComponents(typeof(Component))) { if (!v || v.GetType() == typeof(Transform) || (v.hideFlags & (HideFlags.DontSave | HideFlags.HideInInspector)) != 0) { continue; } IndexPropertyComponents(documentIndex, "t", v.GetType().Name); if (settings.options.properties) { IndexObject(documentIndex, v, dependencies: settings.options.dependencies); } } } var importSettings = AssetImporter.GetAtPath(path); if (importSettings) { IndexObject(documentIndex, importSettings, dependencies: settings.options.dependencies, recursive: true); } if (!wasLoaded || isPrefab) { if (isPrefab && mainAsset is GameObject prefabObject) { PrefabUtility.UnloadPrefabContents(prefabObject); } else if (mainAsset && !mainAsset.hideFlags.HasFlag(HideFlags.DontUnloadUnusedAsset) && !(mainAsset is GameObject) && !(mainAsset is Component) && !(mainAsset is AssetBundle)) { Resources.UnloadAsset(mainAsset); } } } if (settings.options.extended) { IndexSceneDocument(path, checkIfDocumentExists); } if (settings.options.dependencies) { foreach (var depPath in AssetDatabase.GetDependencies(path, false)) { if (path == depPath) { continue; } AddReference(documentIndex, depPath); } } }
public override void IndexDocument(string path, bool checkIfDocumentExists) { var documentIndex = AddDocument(path, checkIfDocumentExists); AddDocumentHash(path, GetDocumentHash(path)); if (documentIndex < 0) { return; } IndexWordComponents(documentIndex, path); try { var fileName = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); IndexWord(documentIndex, fileName, fileName.Length, true); IndexProperty(documentIndex, "name", fileName, saveKeyword: false); IndexWord(documentIndex, path, path.Length, exact: true); IndexProperty(documentIndex, "id", path, saveKeyword: false, exact: true); if (path.StartsWith("Packages/", StringComparison.Ordinal)) { IndexProperty(documentIndex, "a", "packages", saveKeyword: true, exact: true); } else { IndexProperty(documentIndex, "a", "assets", saveKeyword: true, exact: true); } if (!String.IsNullOrEmpty(name)) { IndexProperty(documentIndex, "a", name, saveKeyword: true, exact: true); } var fi = new FileInfo(path); if (fi.Exists) { IndexNumber(documentIndex, "size", (double)fi.Length); IndexProperty(documentIndex, "ext", fi.Extension.Replace(".", "").ToLowerInvariant(), saveKeyword: false); IndexNumber(documentIndex, "age", (DateTime.Now - fi.LastWriteTime).TotalDays); IndexProperty(documentIndex, "dir", fi.Directory.Name.ToLowerInvariant(), saveKeyword: false); IndexProperty(documentIndex, "t", "file", saveKeyword: false, exact: true); } else if (Directory.Exists(path)) { IndexProperty(documentIndex, "t", "folder", saveKeyword: false, exact: true); } var at = AssetDatabase.GetMainAssetTypeAtPath(path); var hasCustomIndexers = HasCustomIndexers(at); if (settings.options.types && at != null) { IndexWord(documentIndex, at.Name); while (at != null && at != typeof(Object) && at != typeof(GameObject)) { IndexProperty(documentIndex, "t", at.Name, saveKeyword: true); at = at.BaseType; } } else if (at != null) { IndexProperty(documentIndex, "t", at.Name, saveKeyword: true); } if (settings.options.properties || hasCustomIndexers) { bool wasLoaded = AssetDatabase.IsMainAssetAtPathLoaded(path); var mainAsset = AssetDatabase.LoadMainAssetAtPath(path); if (!mainAsset) { return; } #if !UNITY_2020_2_OR_NEWER var labels = AssetDatabase.GetLabels(mainAsset); #else var guid = AssetDatabase.GUIDFromAssetPath(path); var labels = AssetDatabase.GetLabels(guid); #endif foreach (var label in labels) { IndexProperty(documentIndex, "l", label, saveKeyword: true); } if (hasCustomIndexers) { IndexCustomProperties(path, documentIndex, mainAsset); } if (settings.options.properties) { if (!String.IsNullOrEmpty(mainAsset.name)) { IndexWord(documentIndex, mainAsset.name, true); } var prefabType = PrefabUtility.GetPrefabAssetType(mainAsset); if (prefabType == PrefabAssetType.Regular || prefabType == PrefabAssetType.Variant) { IndexProperty(documentIndex, "t", "prefab", saveKeyword: true); } if (settings.options.properties) { IndexObject(documentIndex, mainAsset); } if (mainAsset is GameObject go) { foreach (var v in go.GetComponents(typeof(Component))) { if (!v || v.GetType() == typeof(Transform)) { continue; } IndexPropertyComponents(documentIndex, "t", v.GetType().Name); IndexPropertyComponents(documentIndex, "has", v.GetType().Name); if (settings.options.properties) { IndexObject(documentIndex, v, dependencies: settings.options.dependencies); } } } } if (!wasLoaded) { if (mainAsset && !mainAsset.hideFlags.HasFlag(HideFlags.DontUnloadUnusedAsset) && !(mainAsset is GameObject) && !(mainAsset is Component) && !(mainAsset is AssetBundle)) { Resources.UnloadAsset(mainAsset); } } } if (settings.options.dependencies) { foreach (var depPath in AssetDatabase.GetDependencies(path, true)) { if (path == depPath) { continue; } var depName = Path.GetFileNameWithoutExtension(depPath); IndexProperty(documentIndex, "ref", depName, saveKeyword: false); IndexProperty(documentIndex, "ref", depPath, saveKeyword: false, exact: true); } } } catch (Exception ex) { Debug.LogException(ex); } }