ResourceLoadContextclass

Lets a `Sandbox.Resource` read from its compiled file while the file data is in memory, during `Sandbox.Resource.OnLoaded(Sandbox.ResourceLoadContext)`. Blocks are written at compile time, eg with `Sandbox.Resources.ResourceCompileContext.WriteBlockJson(System.String,System.Object)`. Only valid during the call - copy out anything you want to keep.

objectResourceLoadContext
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed struct Sandbox.ResourceLoadContext

Methods4

Showing 4 methods

public bool Exists(string blockName)PUBLIC

Does the compiled file contain this block? Block names are four character codes, eg "LIPS".

ParameterTypeDescription
blockNamestring
Returns:bool

public System.ReadOnlySpan`1<byte> ReadData(string blockName)PUBLIC

Read a named block's data. The span points directly into the loaded file, so it's only valid during `Sandbox.Resource.OnLoaded(Sandbox.ResourceLoadContext)` - copy anything you want to keep.

ParameterTypeDescription
blockNamestring
Returns:ReadOnlySpan<byte>

public T ReadJson(string blockName, T defaultValue = null)PUBLIC

Read a named block as json, eg `context.ReadJson>( "LIPS" )`.

ParameterTypeDescription
blockNamestring
defaultValue = nullT
Returns:T

public string ReadString(string blockName)PUBLIC

Read a named block as a utf-8 string, or null if the block doesn't exist.

ParameterTypeDescription
blockNamestring
Returns:string

On this page