Skip to content

UnityAddressablesGreedyFS

Namespace: Shadop.Archmage.Sdk

Implements the IFS interface to load files via Unity Addressables, reading all files in each encountered asset bundle in one go. Only LoadAtlasAsync is supported, and it must be called from the main thread.

public class UnityAddressablesGreedyFS : IFS

Inheritance Object → UnityAddressablesGreedyFS
Implements IFS

Remarks:

On WebGL, UnityAddressablesFS takes about one frame per file, because Unity completes at most one asynchronous asset load per frame. This class instead reads every file in an asset bundle synchronously the first time a file in that bundle is requested, and keeps the other files in memory until they are requested.

This class reads every file in the bundle, so a bundle that also holds other files costs extra time and memory. Keep configs in asset bundles of their own. Files that are never requested stay in memory until the instance is garbage collected.

public bool MainThreadOnly { get; }

Boolean

public UnityAddressablesGreedyFS()
public Byte[] ReadAllBytes(string path)

path String

Byte[]

ReadAllBytesAsync(String, CancellationToken)

Section titled “ReadAllBytesAsync(String, CancellationToken)”
public Task<Byte[]> ReadAllBytesAsync(string path, CancellationToken cancellationToken)

path String

cancellationToken CancellationToken

Task<Byte[]>

Always returns true. For a missing file, ReadAllBytesAsync throws FileNotFoundException.

public bool FileExists(string path)

path String

Boolean

Always returns true. Addressables has no directory concept.

public bool DirectoryExists(string path)

path String

Boolean