API ReferenceSandbox.Resources

ResourceCompileContextclass

objectResourceCompileContext
Namespace
Sandbox.Resources
Assembly
Sandbox.Engine
Declaration
public abstract class Sandbox.Resources.ResourceCompileContext

Constructors1

Showing 1 constructors

Methods12

Showing 12 methods

public virtual void AddCompileReference(string path)PUBLICVIRTUAL

Add a reference that is needed to compile this resource, but isn't actually needed once compiled.

ParameterTypeDescription
pathstring
Returns:void

public virtual void AddGameFileReference(string path)PUBLICVIRTUAL

Add a game file reference. This file will be included in packages but is not a native resource. Use this for arbitrary data files that are loaded by managed code (e.g. navdata files).

ParameterTypeDescription
pathstring
Returns:void

public virtual void AddRuntimeReference(string path)PUBLICVIRTUAL

Add a reference. This means that the resource we're compiling depends on this resource.

ParameterTypeDescription
pathstring
Returns:void

public virtual Sandbox.Resources.ResourceCompileContext.Child CreateChild(string absolutePath)PUBLICVIRTUAL

Create a child resource

ParameterTypeDescription
absolutePathstring
Returns:Child

public virtual byte[] ReadSource()PUBLICVIRTUAL

Read the source, either from in memory, or from disk

Returns:byte[]

public System.Text.Json.Nodes.JsonObject ReadSourceAsJson()PUBLIC

Read the source, either from in memory, or from disk

Returns:JsonObject

public string ReadSourceAsString()PUBLIC

Read the source, either from in memory, or from disk

Returns:string

public virtual string ScanJson(string json)PUBLICVIRTUAL

Load the json and scan it for paths or any embedded resources

ParameterTypeDescription
jsonstring
Returns:string

public void WriteBlock(string blockName, System.ReadOnlySpan`1<byte> data)PUBLIC

ParameterTypeDescription
blockNamestring
dataReadOnlySpan<byte>
Returns:void

public void WriteBlockJson(string blockName, object obj)PUBLIC

Serialize an object to json and write it to a named block in the compiled resource. Read it back at runtime in `Sandbox.Resource.OnLoaded(Sandbox.ResourceLoadContext)`.

ParameterTypeDescription
blockNamestring
objobject
Returns:void

Properties5

Showing 5 properties

public virtual string Sandbox.Resources.ResourceCompileContext.AbsolutePath { get; set; }PUBLICVIRTUALGETSET

The absolute path to the resource on disk

Returns:string

public virtual string Sandbox.Resources.ResourceCompileContext.RelativePath { get; set; }PUBLICVIRTUALGETSET

The path relative to the assets folder

Returns:string

public virtual int Sandbox.Resources.ResourceCompileContext.ResourceVersion { get; set; }PUBLICVIRTUALGETSET

The resource version can be important

Returns:int

On this page