/// <summary> /// Gets all variants of all resources in a folder /// </summary> /// <remarks> /// <para>This returns [resources][variants] which is sideways from the old convention</para> /// </remarks> public T[][] GetResourcesAllVariants <T>(string path, bool typeExact) where T : UnityEngine.Object { if (path.StartsWith("Game/") || path.StartsWith("Core/"))// || path.StartsWith("Addons/")) //actually the Addons path is probably safe; it's just loading virtual elocal { Debug.LogWarning($"Resource path starts with special folder, this case isn't currently handled! ({path})"); } string folder = GetAsFolderPath(path); ResourceFolder rFolder = RetrieveResourceFolder(folder); return(rFolder.GetResourcesAll <T>(typeExact)); }
//gets a resource folder from the dictionary if it exists, creates it if it does not internal ResourceFolder RetrieveResourceFolder(string folderPath) { if (ResourceFolders.TryGetValue(folderPath, out var folder)) { return(folder); } ResourceFolder rf = new ResourceFolder(folderPath); ResourceFolders.Add(folderPath, rf); return(rf); }
/// <summary> /// Checks if a resource exists /// </summary> /// <remarks> /// <para>Note that this *can* be faster than GetResource depending on caching and backing type</para> /// </remarks> public bool ResourceExists <T>(string path, bool typeExact) where T : UnityEngine.Object { if (path.StartsWith("Game/") || path.StartsWith("Core/"))// || path.StartsWith("Addons/")) { Debug.LogWarning($"Resource path starts with special folder, this case isn't currently handled! ({path})"); } string folder = GetFolderName(path); ResourceFolder rFolder = RetrieveResourceFolder(folder); string file = GetFileName(path); ResourceObject rObject = rFolder.RetrieveResourceObject(file); return(rObject.ExistsForType <T>(typeExact)); }
internal ResourceObject RetrieveResourceObject(string path) { ResourceObject rObject; if (!ResourceObjectCache.TryGetValue(path, out rObject)) { string folder = GetFolderName(path); ResourceFolder rFolder = RetrieveResourceFolder(folder); string file = GetFileName(path); rObject = rFolder.RetrieveResourceObject(file); ResourceObjectCache.Add(path, rObject); } return(rObject); }