Types and grammar
This page lists the Core types that read and write cell text: custom cell types, the sheet grammar constants, asset references, and the visual value types. Every type on this page is in the SheetForge.Core.Model namespace.
Custom cell types
These types let a plugin add a cell type, a wrapper type or a marker row.
| Type | Role |
|---|---|
ICellValueParser | Parses one scalar cell |
ICustomCellType | Optional helper for codegen and the round trip |
IReferencingCellType | Opt-in capability for a parser whose notation holds a key |
IRefBearingValue | The value-side half of IReferencingCellType |
ICellWrapperType | A generic wrapper value shape, MyWrapper<T> |
WrapperValue | The parsed intermediate representation (IR) of a wrapper cell |
IStructuralMarkerDefinition | A custom @marker row |
MarkerCellContext | One marker-cell validation call |
CellParseContext | The context of one parse call |
To write a cell type step by step, see Enums and cell types.
ICellValueParser
Parses one scalar cell.
string TypeNamebool TryParse(CellParseContext, string, out object)
On failure, collect the error into context.Errors and return false. Never throw.
ICustomCellType
An optional helper for codegen and the round trip.
Type ValueTypebool TryRender(object, out string text, out string reason)
IReferencingCellType
An opt-in capability that a registered ICellValueParser may also implement. With it, a key buried in the parser's own notation gets the full RecordId@Tab treatment:
- Integrity checks and suggestions
- Key-rename propagation, with the payload preserved
- Graph edges and ports
- The
▾picker - Orphan detection (records that nothing references)
- Exported dropdown rules
The Core finds the capability by casting the registered parser. There is no separate registration.
Members:
bool TryGetTokenKey(elementText, out key)string MakeToken(key)bool TryRetargetToken(elementText, newKey, out newText)bool TryRemoveToken(elementText, key, out newText). An empty result means the element disappears.bool TryRewriteKeys(elementText, IReadOnlyDictionary<string,string> renames, out newText)
Rules:
- One call handles one element. An element is the whole cell, or one
;-separated element. - A payload may not contain
;. @targetmust name a real sheet tab. Otherwise the error isUnknownTargetTab.- The members never throw.
falseornullmeans "cannot interpret". - Rewrites preserve the rest of the element's text.
Reference parity shows how to implement the capability.
IRefBearingValue
The value-side half of IReferencingCellType. The parsed value implements it.
IEnumerable<string> ReferencedKeys
Declaration order is the order of diagnostics, and the order in which the suggestion budget is spent. Null and empty entries are skipped.
Both halves are needed. The scanner reads IRefBearingValue, and the text hooks of IReferencingCellType rewrite the cell. A parsed value cannot restore the author's notation, and text cannot be validated without being read.
ICellWrapperType
A generic wrapper value shape, MyWrapper<T>. For example, Pair<int> is written 1~2. The wrapper owns the outer syntax, and the Core parses the inner type recursively.
string Namebool TrySplit(string, out IReadOnlyList<string> pieces, out string reason)string JoinCanonical(IReadOnlyList<string>)Type OpenClrTypeobject Assemble(IReadOnlyList<object>, Type closed)bool TryDisassemble(object, out IReadOnlyList<object>, out string reason)
WrapperValue
The parsed IR of a wrapper cell. It carries the wrapper strategy and exposes the inner CellValues. References inside a wrapper therefore pass through validation, key and tab rename, and Export.
ICellWrapperType WrapperIReadOnlyList<CellValue> Inner
IStructuralMarkerDefinition
A custom @marker row. The row holds per-column values and is validated column by column. It generalizes @overlap.
string MarkerName, without the@string Descriptionvoid ValidateCell(MarkerCellContext)
MarkerCellContext
One marker-cell validation call.
string MarkerNamestring RawTextstring FieldNameCellCoordinate Coordinatevoid Reject(string reason, string suggestion = null). A rejection producesMarkerCellInvalid.
CellParseContext
The context of one parse call.
TypeToken TypeCellCoordinate CoordinateErrorCollector ErrorsEnumRegistry Enums
Sheet grammar constants
A plugin that reads or writes cell text works in the same grammar the importer does. It splits a list cell, composes an @type string, or checks whether a name is already taken.
| Type | Kind | Role |
|---|---|---|
SheetSyntax | static class | The sheet grammar as constants |
These constants are the grammar's single source of truth. Use them instead of copying a separator into your plugin, because a copied character goes out of date when the grammar changes.
The lists are handed out read-only, so nothing a plugin does can change the grammar itself.
Sheet syntax documents the notation in full. SheetSyntax is the programmatic handle on it.
Markers
| Constant | Holds |
|---|---|
CommentPrefix | # |
MarkerPrefix | @ |
RequiredMarkers | The three markers every sheet must carry |
ReservedMarkers | Every built-in marker name |
Each built-in marker row has its own constant: NameMarker, TypeMarker, DescMarker, OverlapMarker, StyleMarker, EnumMarker and LocMarker.
Read ReservedMarkers before you name a custom marker. A collision is refused at registration.
Separators
ListSeparator (;) separates list elements.
These constants separate the layers inside one value:
EntrySeparator(,)FieldSeparator(:)SectionSeparator(|)KeyTimeSeparator(@)
Because those layers have separators of their own, ; never appears in a value's own text.
StyleKeyValueSeparator (=) is used inside a @style cell.
Type notation
These constants spell the @type notation:
OptionalSuffix(?)DefaultSeparator(=)TargetSeparator(@, as inRecordId@Tab)ListTypeNameListOpen(List<)ListClose(>)
Type names
Each built-in type name has its own constant: IntTypeName, FloatTypeName, BoolTypeName, StringTypeName, RecordIdTypeName, IntIdTypeName, AssetRefTypeName, ResourceRefTypeName, DirectRefTypeName, LocRefTypeName, ColorTypeName, AnimationCurveTypeName, GradientTypeName and EnumTypeName.
BuiltinScalarTypes and IsBuiltinScalarTypeName(name) tell whether a name is already a built-in. Check a name with them before you register a parser under it.
DeliveryGatedTypeNames lists the built-in cell types whose use depends on the delivery mode: AssetRef and ResourceRef.
Name lists
| Constant | Holds |
|---|---|
StyleKeyNames | title, color |
LocReservedColumns | smart, comment |
Values
TrueCanonical and FalseCanonical hold the canonical bool text.
NumberCellStyles is the NumberStyles SheetForge reads every numeric cell with. Thousands separators are excluded, and the culture is always InvariantCulture. A decimal comma from a locale therefore fails to parse instead of silently changing a number.
Typed asset references
The <Type> in AssetRef@Group<Type>, ResourceRef<Type> and DirectRef<Type> is resolved by the host.
The Core knows neither the engine nor the project's assemblies. It only judges the result. Everything here is pure data.
| Type | Kind | Role |
|---|---|---|
IAssetTypeResolver | interface | Resolves one type name to one verdict |
AssetTypeResolution | sealed class | The verdict for one name |
AssetTypeResolutionStatus | enum | The status of a verdict |
IAssetTypeResolver
AssetTypeResolution Resolve(string rawName)
One name goes in and one verdict comes out. The same name always gets the same answer, so implementations may cache.
The resolver is injected into ImportPipeline separately from AssetKeyIndex. Type names are therefore resolved even in a project that has no Addressables settings yet.
When no resolver is injected, as in a headless or browser host, the type-name diagnostics are not produced.
The Editor's implementation resolves against the project's loaded asset types that derive from UnityEngine.Object. It has no allow-list. It excludes components and editor-only types.
AssetTypeResolution
The verdict for one name.
RawNameAssetTypeResolutionStatus StatusFullName. The CLR full name, with+for nested types. Set forResolvedandNotReferenceableonly.AssemblyName. The assembly that the generated companion assembly must reference. Set for assembly-definition types, andnullfor engine modules and unresolved names.Candidates. Never null. Holds the ambiguous candidates, or the nearest-match suggestions for an unknown name.
Factories:
Resolved(raw, fullName, assemblyName)Unknown(raw, suggestions)Ambiguous(raw, candidates)NotReferenceable(raw, fullName, assemblyName)
AssetTypeResolutionStatus
| Value | Meaning |
|---|---|
Resolved | The name resolved |
Unknown | No such type |
Ambiguous | The short name matches several types and no single concrete one. Write the full name |
NotReferenceable | The type lives in a predefined assembly such as Assembly-CSharp, which generated code cannot reference |
Generated field types
Codegen reads the resolved dictionary that the pipeline produces. For a resolved name it emits AssetReferenceT<global::FullName>.
A name that codegen cannot find in that dictionary is never emitted verbatim. The field falls back to AssetReference, and an AssetTypeUnresolvedFallback warning is collected.
The resolved full name is also mixed into the schema fingerprint.
Asset delivery
These types hold the cell values of the two asset cell types that need no Addressables catalog, and the inputs that the delivery-mode verdict on them is made from. They also hold the check on which gated cell types a mode accepts.
All of it is pure data. The editor fills the indexes and hands the mode's verdict in.
| Type | Kind | Role |
|---|---|---|
ResourceRefValue | readonly struct | The parse result of a ResourceRef cell |
DirectRefValue | readonly struct | The parse result of a DirectRef cell |
DirectRefKind | enum | Which spelling a DirectRef cell used |
ResourceAssetIndex | sealed class | What exists under the project's Resources folders, by lookup path |
ProjectAssetIndex | sealed class | The project assets the sheets mention |
DeliveryContext | sealed class | The active mode as validation sees it |
ResourceRefValue
The parse result of a ResourceRef cell.
Path. Relative to theResourcesfolder, in canonical form:/separators, no extension, case kept.SubNameIsEmptyToString(). The cell spelling,path[sub].
DirectRefValue
The parse result of a DirectRef cell.
Kind. ADirectRefKind.Identity. TheAssets/…path, or the lower-case GUID.SubNameIsEmptyToString()
DirectRefKind
Which spelling the cell used. A cell keeps the one it has.
PathGuid
ResourceAssetIndex
What exists under the project's Resources folders, by lookup path.
Register(path)RegisterTyped(path, satisfiedTypeFullNames)RegisterDuplicate(path)HasPathIsDuplicateHasTypeInfoSatisfiesType(path, typeFullName)PathsDuplicatePaths
When the index is injected as null, as in the browser or a headless host, ResourceRef validation is skipped.
ProjectAssetIndex
The project assets the sheets mention. The index maps each path to its GUID and type closure, and each GUID to its path.
Register(path, guid, satisfiedTypeFullNames)HasPathGuidOf(path)PathOf(guid)HasTypeInfoSatisfiesTypePaths
The index is filled with what the sheets refer to, not with the whole project.
When the index is injected as null, DirectRef validation is skipped.
DeliveryContext
The active mode as validation sees it.
IdGatedTypeNames. The set of types the gate can refuse, which isSheetSyntax.DeliveryGatedTypeNames.AllowedGatedTypes. What this mode honors.IsGated(typeName)Allows(typeName). True for every type outside that set, and for a gated type this mode accepts.
A null context means "do not judge the gate".
Visual value types
These are engine-free value models for the three built-in visual types. Each model is immutable and IEquatable. Each owns its own text form through TryParse and Render.
The text form is the notation that Visual types documents. A plugin type that stores a color, a curve or a gradient can reuse these models instead of inventing a second notation.
The Editor bakes the models into UnityEngine.Color, AnimationCurve and Gradient, and reads them back. The browser samples them through the evaluators below rather than re-implementing the math.
| Type | Kind | Role |
|---|---|---|
ColorValue | readonly struct | A color as four bytes |
CurveValue | sealed class | A curve: its keys and wrap modes |
CurveKey | readonly struct | One key of a curve |
CurveWrap | enum | Unity's wrap vocabulary by name |
CurveTangentMode | enum | Tangent modes, identical to AnimationUtility.TangentMode |
CurveWeightedMode | [Flags] enum | Which side of a key uses weighted (Bezier) tangents |
CurveTangentSolver | static class | Derives the tangent numbers a mode dictates |
CurveEvaluator | static class | Evaluates and samples a curve |
GradientValue | sealed class | A gradient: its keys, blend mode and color space |
GradientColorKey | readonly struct | One color key of a gradient |
GradientAlphaKey | readonly struct | One alpha key of a gradient |
GradientBlend | enum | How a gradient blends |
GradientColorSpace | enum | The color space of a gradient |
GradientEvaluator | static class | Evaluates and samples a gradient |
ColorValue
Four bytes: R, G, B and A.
- static
Default. The value#00000000. - static
TryParse(text, out value, out error). Accepts#RGB,#RGBA,#RRGGBBand#RRGGBBAA. Render(). Upper-case, six digits when opaque.
CurveValue
Keys. Time-ascending.PreWrapandPostWrap- static
Empty. No keys. It is the only state with no text form, andRender()gives"". - static
Create(keys, preWrap, postWrap). The one construction path. - static
TryParse. Accepts keys of 2, 4, 7 or 8 fields,Onceas an alias ofClampForever, andInfinityor-Infinitytangents. Render(). Writes 8-field keys, and the wrap suffix only when needed.
Create sorts by time, rejects duplicate times, and applies CurveTangentSolver, so the tangent modes take precedence over the stored tangent numbers from the moment a curve exists.
CurveKey
TimeValueInTangentOutTangentInWeightOutWeightCurveWeightedMode WeightedModeCurveTangentMode LeftModeandRightModebool Broken
The constructor takes ten arguments and does no normalization of its own.
CurveWrap
Unity's wrap vocabulary by name. The value mapping to WrapMode belongs to the baker.
ClampForeverLoopPingPongDefault
CurveTangentMode
Free = 0Auto = 1Linear = 2Constant = 3ClampedAuto = 4
The names and values are identical to AnimationUtility.TangentMode. The baker therefore maps by name and never touches Unity's packed tangent bits.
CurveWeightedMode
A [Flags] enum. It says which side of a key uses weighted (Bezier) tangents.
None = 0In = 1Out = 2Both = 3
CurveTangentSolver
CurveKey[] Apply(IReadOnlyList<CurveKey> sortedKeys)
Apply derives the tangent numbers a mode dictates. It applies the stages in the engine's order:
Linearon its own sideClampedAutoon both sidesAutoon both sidesConstanton its own side
Free sides and weights stay untouched.
CurveValue.Create calls the solver, so callers rarely do.
CurveEvaluator
float Evaluate(CurveValue, float time)float[] Sample(CurveValue, int count). Needscount ≥ 2. The samples are evenly spaced from the first key to the last.
The evaluator uses:
- Hermite interpolation between keys
- Weighted Bezier on the sides whose weight flag is set
- A hold when a tangent is infinite
- The four wrap behaviors outside the key range
It is verified against AnimationCurve.Evaluate on random curves.
GradientValue
ColorKeysandAlphaKeys. 1 to 8 each, time-ascending.GradientBlend ModeGradientColorSpace ColorSpace- static
Default. White, fully opaque,Blend. - static
Create(colorKeys, alphaKeys, mode, colorSpace). Validates counts and 0…1 ranges, quantizes times to 16 bits as Unity does, and sorts stably. - static
TryParse. Reads three or four|-separated sections. Render()
GradientColorKey
ColorValue Color. Alpha is ignored, because alpha has its own keys.float Time
GradientAlphaKey
float Alphafloat Time
GradientBlend
BlendFixedPerceptualBlend
GradientColorSpace
Uninitialized. Not written. Reads asGamma.GammaLinear
The color space affects only PerceptualBlend.
GradientEvaluator
ColorValue Evaluate(GradientValue, float time)ColorValue[] Sample(GradientValue, int count)
Blending is linear, stepped or perceptual (Oklab). The alpha keys are blended separately, and the result is rounded to bytes.
It is verified against Gradient.Evaluate on random gradients.
Next steps
- Enums and cell types
Write a custom cell type and a wrapper type.
- Reference parity
Give a key in your own notation the full reference treatment.
- Sheet syntax
The notation that the grammar constants spell out.
- Visual types
The text form of colors, curves and gradients.