Runtime assembly
This page lists the public types of SheetForge.Runtime and the pattern of the types that codegen emits. The assembly is autoReferenced, so game code can use it without an asmdef reference.
Types
| Type | Kind | Role |
|---|---|---|
SheetForgeDatabases | static | The runtime loader |
SheetForgeLoadHandle<TAsset> | sealed class | The result of one load, whichever mode produced it |
SheetForgeLoadStatus | enum | Pending · Succeeded · Failed |
SheetForgeLoadAwaiter<TAsset> | readonly struct | The awaiter behind await handle |
DefinitionDatabase | abstract ScriptableObject | Base of every generated per-tab Database |
RecordRef | struct | The serialized reference value inside baked ScriptableObjects |
IntRef | struct | The serialized integer-key reference value |
LocRef | struct | The serialized localization reference |
LocRefExtensions | static | Conversion of a LocRef to a LocalizedString |
ResourceRef<TAsset> | serializable struct, TAsset : UnityEngine.Object | The baked form of a ResourceRef cell |
IDatabaseLoader | interface | The runtime half of a delivery mode |
SheetForgeDeliveryIds | static | The ids of the three built-in modes |
SheetForgeCatalog | sealed ScriptableObject | What the scene catalogue mode bakes beside the databases |
SheetForgeCatalogProvider | sealed MonoBehaviour | The one setup step of the scene catalogue mode |
SheetForgeRuntimeInfo | static | const Version |
SheetForgeDatabases
SheetForgeDatabases is the runtime loader. It is the sanctioned load path, identical in every delivery mode.
Load and release
| Call | Returns |
|---|---|
LoadAsync(tab) | SheetForgeLoadHandle<DefinitionDatabase> |
LoadAsync<TDatabase>(tab) | SheetForgeLoadHandle<TDatabase> |
To release a load, call Release<TDatabase>(handle) or Release(DefinitionDatabase).
The address members are const AddressPrefix = "SheetForge/" and AddressFor(tab).
Tab registration
Register(deliveryId, tabNames) names the tabs that a workbook delivers. Each workbook's generated {Settings}_{guid8}DeliveryRegistration class calls it before the first scene. This is what lets one project mix modes.
The call is idempotent. A tab claimed for a second, different mode keeps the first mode and logs one warning.
DeliveryIdFor(tab) returns the mode a registration named for that tab. It returns null when nobody registered the tab. A tab that nobody registered still loads, through the default mode.
The default mode
Configure(deliveryId) sets the default mode for tabs no registration named. It is a plugin's call, or a hand-written bootstrap's. The first caller wins. A second, different id logs a warning.
ActiveDeliveryId is the default mode. It is null until one is stated. Unregistered tabs then fall back to Addressables, which is what code generated before delivery modes existed expects.
Loaders and catalogues
RegisterLoader(deliveryId, IDatabaseLoader) registers a plugin's mode. Registering an id twice replaces the earlier loader.
RegisterCatalog and UnregisterCatalog are called by SheetForgeCatalogProvider.
Failed loads
A handle is never null. A request that cannot be served comes back finished and failed, with the reason on Error.
A load fails when nobody registered the tab and the mode has no loader. The message says so first: "registered by no workbook's delivery registration", followed by "re-import that workbook".
Compiling without Addressables
Everything in SheetForgeDatabases compiles without the Addressables package. Only the Addressables loader itself sits behind SHEETFORGE_ADDRESSABLES. Without the package, a load in that mode fails with a message that names the missing package.
Load handles
SheetForgeLoadHandle
SheetForgeLoadHandle<TAsset> is the result of one load, whichever mode produced it.
| Member | Behavior |
|---|---|
Status | A SheetForgeLoadStatus value |
Error | Plain words. Null unless the load failed |
Completed event | A listener added after completion is called at once |
WaitForCompletion() | Blocks where the loader can. Otherwise it fails the handle with a message |
Release() | Once per load. A second call is a no-op |
GetAwaiter() | Makes await handle work |
The handle also has IsDone, Result and SupportsSynchronousCompletion.
With await handle, a failed load yields null rather than throwing.
Members for loader authors
A loader builds a handle with the constructor (Action completeSynchronously, Action<handle> release). It completes the handle with SetResult or SetError.
The static members FromResult and FromError return a finished handle.
SheetForgeLoadStatus
The enum has three values: Pending, Succeeded and Failed.
SheetForgeLoadAwaiter
SheetForgeLoadAwaiter<TAsset> is the awaiter behind await handle. It is hand-written, so the feature compiles on every supported editor and allocates no Task.
Members:
IsCompletedOnCompletedGetResult
DefinitionDatabase
DefinitionDatabase is the base of every generated per-tab Database.
Members:
abstract TabNameabstract Countvirtual IReadOnlyList<object> RecordsUntypedvirtual InvalidateIndex()
Enumerate a tab without its type
RecordsUntyped is the sanctioned way to enumerate a baked tab without knowing its generated type. It serves code such as a second baker, or an inspector that walks every tab.
Without this member, such code has to read the private records field through .NET reflection. That makes a field name an undeclared contract, which breaks silently the day codegen renames the field.
Treat the list as read-only, because the sheet is canonical.
The member defaults to empty. Generated code from before this member existed still compiles and runs. A re-import emits the override.
Reference values
Reference cells are baked into these value types.
RecordRef
RecordRef is the serialized reference value inside baked ScriptableObjects. It holds a string id, resolved at lookup.
Members:
IdIsEmpty
IntRef
IntRef is the serialized integer-key reference value inside baked ScriptableObjects. It is the twin of RecordRef for IntId@Tab fields.
Members:
IdIsEmpty
Because 0 is a valid id, a hasValue bit backs IsEmpty.
Codegen emits an IntId@Tab field as IntRef. TryGet(IntRef) on the generated Database consumes it.
LocRef
LocRef is the serialized localization reference inside baked ScriptableObjects. It is the baked form of a LocRef@Tab cell.
| Member | Meaning |
|---|---|
Table | The localization tab, which is the String Table collection name |
long KeyId | 0 means "not resolved yet" |
The struct also has Key and IsEmpty.
An import bakes a KeyId of 0. The Unity Localization bridge fills the real id in after a table sync, so a reference survives a key rename. See Rename a key.
LocRef always compiles. Generated code and baked assets never contain a localization-package type. That keeps the package optional.
LocRefExtensions
LocRefExtensions has one member, LocalizedString ToLocalizedString(this LocRef).
| Reference | Result |
|---|---|
KeyId is not 0 | Points by KeyId |
KeyId is 0 | Points by key name |
| Empty | An empty LocalizedString |
The class exists only when com.unity.localization is installed, under the SHEETFORGE_LOCALIZATION version-define. SHEETFORGE_ADDRESSABLES uses the same arrangement for the Addressables layer.
ResourceRef
ResourceRef<TAsset> is the baked form of a ResourceRef cell. The constraint is TAsset : UnityEngine.Object.
| Member | Behavior |
|---|---|
Path | Relative to the Resources folder, no extension |
Load() | Resources.Load, or LoadAll plus a name match for a sub-asset |
LoadAsync() | Returns SheetForgeLoadHandle<TAsset> |
ToString() | The cell spelling |
The struct also has SubName and IsEmpty.
LoadAsync() on an empty reference comes back failed. On a sub-asset reference it comes back already finished, because Resources has no asynchronous call that reaches inside an asset.
ResourceRef<TAsset> is a value type. It sits in a List<> or a wrapper like the other cell values.
Delivery modes
IDatabaseLoader
IDatabaseLoader is the runtime half of a delivery mode. To write one, see Custom delivery.
Members:
SheetForgeLoadHandle<TDatabase> Load<TDatabase>(string key)bool SupportsSynchronousCompletionvoid Release(object loaded)
Load never returns null.
SheetForgeDeliveryIds
SheetForgeDeliveryIds holds the ids of the three built-in modes:
Addressables = "addressables"Resources = "resources"Direct = "direct"
Ids are compared trimmed and lower-cased.
SheetForgeCatalog
SheetForgeCatalog is what the scene catalogue mode bakes beside the databases. It is the list of this workbook's Databases, referenced outright.
| Member | Note |
|---|---|
Databases | Read-only |
TryGet(key, out database) | Accepts "SheetForge/{tab}" or the bare tab name |
SetDatabases(…) | The bake's member. The list is a cache, like every bake output |
SheetForgeCatalogProvider
SheetForgeCatalogProvider is the one setup step of the scene catalogue mode. Drop it on a GameObject in the first scene and drag the catalogue onto its Catalog field.
- The provider registers in
Awakeand unregisters inOnDestroy. - Assigning
Cataloglater re-registers. - Several providers may be alive at once, one workbook each.
SheetForgeRuntimeInfo
SheetForgeRuntimeInfo has one member, const Version.
Generated types
Generated types are a pattern, per project. They are not shipped API.
For each tab Foo, codegen emits into your generatedNamespace:
public sealed partial class FooDefinition // one strongly-typed field per column; @desc → doc/tooltip
public sealed partial class FooDatabase : DefinitionDatabase
{
// TabName, Count, SchemaFingerprint, Records, RecordsUntyped override,
// lazy _byId/_byIntId lookups, InvalidateIndex override
}Load with SheetForgeDatabases.LoadAsync<FooDatabase>("Foo").
The delivery registration class
Alongside the tab files, every import writes one {Settings}_{guid8}DeliveryRegistration.cs. The class is named after the settings asset and the first eight characters of its GUID. It is marked [Preserve].
Its only member runs at RuntimeInitializeLoadType.SubsystemRegistration. The member calls SheetForgeDatabases.Register("<mode id>", new string[] { "<tab>", … }) with the workbook's tabs. An empty workbook emits new string[0].
That is how a build knows which delivery mode each tab arrives by without reading any editor setting. It is also how two workbooks in one project may differ.
Asset reference fields
| Column | Generated field |
|---|---|
ResourceRef<T> | A ResourceRef<T> field |
DirectRef<T> | A plain T field holding the asset itself. UnityEngine.Object when unrestricted |
Extend the generated classes
Both classes are emitted partial. You can add derived members, such as a computed property, an interface implementation or an operator, in your own file next to the generated one. A re-import does not overwrite that file.
Add no serialized fields in your part. The baked ScriptableObject is rebuilt from the sheet on every import, so anything only your part serializes comes back at its default. If a value belongs to the data, it belongs in a column.
The partial keyword does not touch SchemaFingerprint, which is computed from the schema alone. Making the classes partial invalidates no existing bake.
Next steps
- Getting started
Import a sheet and load it in your game.
- Choose a delivery mode
Compare the three built-in delivery modes.
- Custom delivery
Write a delivery mode of your own.
- Unity Localization bridge
How
LocRefvalues reach Unity Localization.