s&
About
The Project
infoAbout s&box mapRoadmap monitoringMetricsEngine startup and usage numbers
Updates
newspaperLatest News published_with_changesChangesRelease-by-release changelog
Games
Browse Games Discover Games
gamejams
Workshop
Playable
sports_esportsGamesStandalone games and gamemodes
Assets
landscapeMaps view_in_arModels textureMaterials apparelClothing
appsEverythingEvery asset type in one list
Forum
Learn
Documentation
rocket_launchGetting Started docsDocumentation apiAPI Reference
Resources
schoolTutorials manage_searchCode Search
Get s&box
Sign in with Steam
Api
Classes
ResourceLoadContext
chevron_left Classes
struct
ResourceLoadContext

Properties

data_objectIsUncompiled

Methods

functionsExistsfunctionsReadDatafunctionsReadJsonfunctionsReadSourcefunctionsReadSourceAsStringfunctionsReadString
ResourceLoadContext
Lets a Sandbox.Resource read from its 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.
struct Sandbox .
sealedSandbox.Engine

data_object Properties 1

IsUncompiled
bool
Whether this context contains an original source file instead of a compiled resource container.

functions Methods 6

Exists (blockName)
bool
Does the compiled file contain this block? Block names are four character codes, eg "LIPS".
ReadData (blockName)
ReadOnlySpan`1
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.
ReadJson (blockName, defaultValue)
T
Read a named block as json, eg context.ReadJson>( "LIPS" ).
ReadSource ()
ReadOnlySpan`1
Reads the complete uncompiled source file. The returned span is only valid during Resource.OnLoaded.
ReadSourceAsString ()
string
Reads the uncompiled source file as UTF-8 text, removing an optional byte order mark. The returned string can be retained after Resource.OnLoaded returns.
ReadString (blockName)
string
Read a named block as a utf-8 string, or null if the block doesn't exist.
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.
Facepunch
  • News
  • Docs
  • Metrics
  • FAQ
  • Forum
  • Discord
  • Twitter