internal static IEnumerable <ResourcesAssetEntry> GetScenes() { foreach (var item in Util.GetAssets <SceneAsset>("", RESOURCES_ROOT_FOLDER)) { var path = AssetDatabase.GetAssetPath(item); yield return(new ResourcesAssetEntry() { address = ResourcesAssetEntry.GetAddress(AssetDatabase.GetAssetPath(item)), asset = item, AssetPath = path }); } }
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); }