Click or drag to resize

ResourceManager Class

A versatile resource management system for loading, unloading, caching, reading, saving and parsing assets with support for modding and async methods.
Inheritance Hierarchy
SystemObject
  KitResourceManager

Namespace:  Kit
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0
Syntax
C#
public static class ResourceManager
Request Example View Source

The ResourceManager type exposes the following members.

Methods
  NameDescription
Public methodStatic memberClearCache
Clear the cache and (optionally) unload assets not in use.
Public methodStatic memberClearCacheAsync
Clear the cache and unload assets not in use asynchronously.
Public methodStatic memberComparePath
Returns whether two paths are equal.
Public methodStatic memberCreateDirectoryForFile
Create directories for a file.
Public methodStatic memberDelete(String)
Delete a file.
Public methodStatic memberDelete(ResourceFolder, String)
Delete a file.
Public methodStatic memberExists(String)
Returns whether a file exists.
Public methodStatic memberExists(ResourceFolder, String)
Returns whether a file exists.
Public methodStatic memberGetPath(ResourceFolder)
Get the absolute path to a folder.
Public methodStatic memberGetPath(ResourceFolder, String)
Get the absolute path to a file.
Public methodStatic memberLoad(Type, String)
Load a resource from an absolute path with the list of parsers registered. Does not cache.
Public methodStatic memberLoad(Type, ResourceFolder, String, Boolean, Boolean)

Load and cache a resource.

If folder is Resources the asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadT(String)
Load a resource from an absolute path with the list of parsers registered. Does not cache.
Public methodStatic memberLoadT(ResourceFolder, String, Boolean, Boolean)

Load and cache a resource.

If folder is Resources the asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadAsync(Type, String)
Load a resource asynchronously from an absolute path with the list of parsers registered. Does not cache.
Public methodStatic memberLoadAsync(Type, ResourceFolder, String, Boolean, Boolean)

Load and cache a resource asynchronously.

If folder is Resources the asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadAsyncT(String)
Load a resource asynchronously from an absolute path with the list of parsers registered. Does not cache.
Public methodStatic memberLoadAsyncT(ResourceFolder, String, Boolean, Boolean)

Load and cache a resource asynchronously.

If folder is Resources the asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadEx
Load a resource from an absolute path with the list of parsers registered. Does not cache.
Public methodStatic memberLoadExAsync
Load a resource asynchronously from an absolute path with the list of parsers registered. Does not cache.
Public methodStatic memberLoadMerged(Type, ResourceFolder, String)

Load a resource merging the game version with all the mod versions and cache it. Useful to allow modding of configuration files like Json.

If folder is Resources the base asset is loaded with If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadMergedT(ResourceFolder, String)

Load a resource merging the game version with all the mod versions and cache it. Useful to allow modding of configuration files like Json.

If folder is Resources the base asset is loaded with If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadMergedAsync(Type, ResourceFolder, String)

Load a resource asynchronously merging the game version with all the mod versions and cache it. Useful to allow modding of configuration files like Json.

If folder is Resources the base asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadMergedAsyncT(ResourceFolder, String)

Load a resource asynchronously merging the game version with all the mod versions and cache it. Useful to allow modding of configuration files like Json.

If folder is Resources the base asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadUnmodded(Type, ResourceFolder, String)

Load and cache a resource without regarding mods.

If folder is Resources the asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadUnmoddedT(ResourceFolder, String)

Load and cache a resource without regarding mods.

If folder is Resources the asset is loaded with Resources.Load. If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadUnmoddedAsync(Type, ResourceFolder, String)

Load and cache a resource asynchronously without regarding mods.

If folder is Resources the asset is loaded with If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberLoadUnmoddedAsyncT(ResourceFolder, String)

Load and cache a resource asynchronously without regarding mods.

If folder is Resources the asset is loaded with If it's not, it's parsed manually with the list of parsers registered.

Public methodStatic memberMatchExtension(String, IEnumerableString)
Returns whether a path matches one of the extensions specified.
Public methodStatic memberMatchExtension(String, String)
Returns whether a path matches the extension specified.
Public methodStatic memberReadBytes(String)
Read the contents of a file in binary-mode.
Public methodStatic memberReadBytes(ResourceFolder, String, Boolean)
Read the contents of a file in binary-mode.
Public methodStatic memberReadBytesAsync(String)
Read the contents of a file asynchronously in binary-mode.
Public methodStatic memberReadBytesAsync(ResourceFolder, String, Boolean)
Read the contents of a file asynchronously in text-mode.
Public methodStatic memberReadText(String)
Read the contents of a file in text-mode.
Public methodStatic memberReadText(ResourceFolder, String, Boolean)
Read the contents of a file in text-mode.
Public methodStatic memberReadTextAsync(String)
Read the contents of a file asynchronously in text-mode.
Public methodStatic memberReadTextAsync(ResourceFolder, String, Boolean)
Read the contents of a file asynchronously in text-mode.
Public methodStatic memberSave(String, Object)
Save the contents of an object to a file.
Public methodStatic memberSave(ResourceFolder, String, Object)
Save the contents of an object to a file.
Public methodStatic memberSaveAsync(String, Object)
Save the contents of an object asynchronously to a file.
Public methodStatic memberSaveAsync(ResourceFolder, String, Object)
Save the contents of an object asynchronously to a file.
Public methodStatic memberSaveBytes(String, Byte)
Save binary content to a file.
Public methodStatic memberSaveBytes(ResourceFolder, String, Byte)
Save binary content to a file.
Public methodStatic memberSaveBytesAsync(String, Byte)
Save binary content asynchronously to a file.
Public methodStatic memberSaveBytesAsync(ResourceFolder, String, Byte)
Save binary content asynchronously to a file.
Public methodStatic memberSaveText(String, String)
Save text content to a file.
Public methodStatic memberSaveText(ResourceFolder, String, String)
Save text content to a file.
Public methodStatic memberSaveTextAsync(String, String)
Save text content asynchronously to a file.
Public methodStatic memberSaveTextAsync(ResourceFolder, String, String)
Save text content asynchronously to a file.
Public methodStatic memberUnload(Object)
Unload a resource from cache and memory.
Public methodStatic memberUnload(Type, ResourceFolder, String)
Unload a resource from cache and memory.
Public methodStatic memberUnloadT(ResourceFolder, String)
Unload a resource from cache and memory.
Top
Events
  NameDescription
Public eventStatic memberResourceLoaded

Event fired when when any resource is loaded.

Returns the folder, path, reference to the resource and whether the resource was actually loaded () or re-used from cache ().

Public eventStatic memberResourceUnloaded

Event fired when when any resource is unloaded.

Returns the folder and path to the resource unloaded.

Top
Fields
  NameDescription
Public fieldStatic memberLogCategory
Category name to use for logging messages.
Public fieldStatic memberLogEvents
Whether to log load and unload events.
Public fieldStatic memberParsers
Instances of classes to use for parsing data when calling Load / Save methods on a folder other than Resources.
Public fieldStatic memberPaths
Absolute paths to ResourceFolders.
Top
Remarks
Can handle file-names without extensions from Resources. Otherwise you have to provide it, as you can't enumerate and match files in StreamingAssets on platforms like Android.
Examples
ResourceManager.Load<Texture>(ResourceFolder.Resources, "Textures/Background");
ResourceManager.LoadAsync<GameState>(ResourceFolder.PersistentData, "GameState.json");
See Also

Reference