Table of Contents

Class ResourceCache<TAsset>

Namespace
Ceres.Resource
Assembly
Ceres.dll

Loading and cache specific asset as a group and release them by control version

public class ResourceCache<TAsset> : IDisposable, IReadOnlyDictionary<string, TAsset>, IReadOnlyCollection<KeyValuePair<string, TAsset>>, IEnumerable<KeyValuePair<string, TAsset>>, IEnumerable where TAsset : Object

Type Parameters

TAsset
Inheritance
ResourceCache<TAsset>
Implements
Derived
Inherited Members
Extension Methods

Constructors

ResourceCache()

public ResourceCache()

Properties

AddressSafeCheck

Validate asset location before loading, throw InvalidResourceRequestException if not exist

public bool AddressSafeCheck { get; set; }

Property Value

bool

Count

public int Count { get; }

Property Value

int

IsLoading

Flags when any asset is in loading

public bool IsLoading { get; }

Property Value

bool

this[string]

public TAsset this[string key] { get; }

Parameters

key string

Property Value

TAsset

Keys

public IEnumerable<string> Keys { get; }

Property Value

IEnumerable<string>

Values

public IEnumerable<TAsset> Values { get; }

Property Value

IEnumerable<TAsset>

Version

Current cache version

public int Version { get; }

Property Value

int

Methods

ContainsKey(string)

public bool ContainsKey(string key)

Parameters

key string

Returns

bool

Dispose()

Implementation of IDisposable, release all handles in cache.

public virtual void Dispose()

GetCacheKeys()

Get cache addresses

public IEnumerable<string> GetCacheKeys()

Returns

IEnumerable<string>

GetEnumerator()

public IEnumerator<KeyValuePair<string, TAsset>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, TAsset>>

LoadAsset(string)

Load and cache asset in sync way which will block game, not recommend

public TAsset LoadAsset(string address)

Parameters

address string

Returns

TAsset

LoadAssetAsync(string)

Load and cache asset async

public UniTask<TAsset> LoadAssetAsync(string address)

Parameters

address string

Returns

UniTask<TAsset>

ReleaseAssetsAndUpdateVersion()

Release assets with last version and update version

public void ReleaseAssetsAndUpdateVersion()

ReleaseAssetsWithVersion(int)

Release all assets with target version

public void ReleaseAssetsWithVersion(int version)

Parameters

version int

TryGetValue(string, out TAsset)

public bool TryGetValue(string key, out TAsset value)

Parameters

key string
value TAsset

Returns

bool

UpdateVersion()

Update version

public int UpdateVersion()

Returns

int