protected override void Reload() { assets.Clear(); #if USE_ADDRESSABLES assets.AddRange(AddrHelper.GetScenes()); #else assets.AddRange(ResourcesAssetHelper.GetScenes()); #endif }
protected static string CreateAsset(Type type, Type linkType, FieldInfo fieldInfo) { LinkFolderAttribute folderAttr = linkType.GetCustomAttribute <LinkFolderAttribute>(); string defaultFolder = folderAttr != null ? ResourcesAssetHelper.RootFolder + "/" + folderAttr.folder : ResourcesAssetHelper.RootFolder; if (fieldInfo != null && fieldInfo.GetCustomAttribute <LinkFolderAttribute>() != null) { defaultFolder = ResourcesAssetHelper.RootFolder + "/" + fieldInfo.GetCustomAttribute <LinkFolderAttribute>().folder; } string ext = GetExtension(type); if (Directory.Exists(defaultFolder) == false) { Directory.CreateDirectory(defaultFolder); } string path = EditorUtility.SaveFilePanelInProject("Create new " + type.Name, fieldInfo?.Name.FirstCharToUpper(), ext, "Create new " + type.Name, defaultFolder); if (string.IsNullOrEmpty(path)) { return(null); } if (ext == "prefab") { GameObject go = new GameObject(type.Name); go.AddComponent(type); PrefabUtility.SaveAsPrefabAsset(go, path); Object.DestroyImmediate(go); } else { ScriptableObject so = ScriptableObject.CreateInstance(type); AssetDatabase.CreateAsset(so, path); } string address = null; #if USE_ADDRESSABLES AddrHelper.Reload(); AddressableAssetEntry entry = AddrHelper.CreateOrModifyEntry(AssetDatabase.AssetPathToGUID(path)); address = entry.address; #else address = ResourcesAssetEntry.GetAddress(path); #endif AssetDatabase.Refresh(); return(address); }
protected override void Reload() { assets.Clear(); #if USE_ADDRESSABLES if (fieldInfo.GetChildValueType().BaseType.Name.Contains("LinkToScriptable")) { assets.AddRange(AddrHelper.GetScriptableObjectsWithInterface(type)); } else { assets.AddRange(AddrHelper.GetPrefabsWithComponent(type)); } #else if (fieldInfo.GetChildValueType().BaseType.Name.Contains("LinkToScriptable")) { assets.AddRange(ResourcesAssetHelper.GetScriptableObjectsWithInterface(type)); } else { assets.AddRange(ResourcesAssetHelper.GetPrefabsWithComponent(type)); } #endif if (fieldInfo != null) { LinkFilterAttribute interfaceFilter = fieldInfo.GetCustomAttribute <LinkFilterAttribute>(); if (interfaceFilter != null) { assets.RemoveAll(t => { GameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(t.AssetPath); return(go.GetComponent(interfaceFilter.interfaceType) == null); }); } LinkTypeFilterAttribute typeFilter = fieldInfo.GetCustomAttribute <LinkTypeFilterAttribute>(); if (typeFilter != null) { assets.RemoveAll(t => { GameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(t.AssetPath); return(go.GetComponent(typeFilter.type) != null); }); } } }
public static void Validate() { links.Clear(); links.AddRange(FieldReferenceFinder.FindAllFields <Link>()); ShowProgress(0, links.Count); instance.invalidAssets.Clear(); int index = 0; foreach (var data in links) { if (data.property != null && data.property.FindPropertyRelative("Path") != null) { var path = data.property.FindPropertyRelative("Path").stringValue; if (path == Link.NULL) { continue; } var entry = AddrHelper.FindEntry(path); if (entry == null) { if (instance.invalidAssets.Contains(data.asset) == false) { instance.invalidAssets.Add(data.asset); } Debug.LogWarning($"Addressable entry not found! Address {path}, asset: { AssetDatabase.GetAssetPath(data.asset) }"); continue; } if (AssetDatabase.LoadAssetAtPath(entry.AssetPath, typeof(Object)) == null) { if (instance.invalidAssets.Contains(data.asset) == false) { instance.invalidAssets.Add(data.asset); } Debug.LogWarning($"Addressable asset not found: {path}, asset: { AssetDatabase.GetAssetPath(data.asset) }"); } } ShowProgress(index++, links.Count); } EditorUtility.ClearProgressBar(); EditorUtility.SetDirty(instance); Selection.activeObject = instance; }
protected override void Reload() { assets.Clear(); #if USE_ADDRESSABLES assets.AddRange(AddrHelper.GetAssets(type)); #else assets.AddRange(ResourcesAssetHelper.GetAssets(type)); #endif if (fieldInfo != null) { LinkFilterAttribute interfaceFilter = fieldInfo.GetCustomAttribute <LinkFilterAttribute>(); if (interfaceFilter != null) { assets.RemoveAll(t => { Object asset = AssetDatabase.LoadAssetAtPath(t.AssetPath, typeof(Object)); if (type == typeof(MonoBehaviour)) { return(((GameObject)asset).GetComponent(interfaceFilter.interfaceType) == null); } return(interfaceFilter.interfaceType.IsInstanceOfType(asset) == false); }); } LinkTypeFilterAttribute typeFilter = fieldInfo.GetCustomAttribute <LinkTypeFilterAttribute>(); if (typeFilter != null) { assets.RemoveAll(t => { Object asset = AssetDatabase.LoadAssetAtPath(t.AssetPath, typeof(Object)); return(asset.GetType() != typeFilter.type); }); } } }