Class InputCodegenSettings
Where and how the constants file for an action asset is generated.
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
[Serializable]
public class InputCodegenSettings
Remarks
Every field is declarative user intent. Nothing derived is stored here, and in particular no content hash of the generated file: whether the file on disk is current is answered by comparing bytes against it, which cannot go stale the way a recorded hash does when the file is deleted, hand-edited, or resolved from the wrong side of a merge.
The three path-shaped fields are stored empty and resolved at use time by Resolve(string, string), so an action asset that is renamed or moved keeps generating sensibly instead of writing to a path that no longer means anything. A field the user has filled in is always honored as written.
Settings live on the sidecar rather than in editor preferences so they travel with the asset. A colleague who clones the repository regenerates to the same path, in the same namespace, without configuring anything.
Fields
ClassName
Name of the generated type, or empty to derive one from the asset name.
Declaration
[Tooltip("Name of the generated type. Leave empty to derive one from the action asset's name.")]
public string ClassName
Field Value
| Type | Description |
|---|---|
| string |
DEFAULT_CLASS_NAME
Type name used when no class name has been chosen.
Declaration
public const string DEFAULT_CLASS_NAME = "InputActionIDs"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
Fixed rather than derived from the asset name. A project generally generates one constants file and refers to it from everywhere, so a name that tracked whichever asset produced it would only make the call sites harder to read, and would change under a project that renamed its actions asset. It also removes a whole class of invalid name: an asset called "2D Platformer" cannot produce a type starting with a digit if the type name never comes from the asset.
DEFAULT_NAMESPACE
Namespace used when neither the settings nor the project name one.
Declaration
public const string DEFAULT_NAMESPACE = "Game.Input"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
A project that configures a root namespace still wins: this is the last resort, and it exists because Unity leaves the root namespace empty by default, which used to leave a new asset unable to generate until someone typed a namespace by hand.
EmitAccessors
Whether to emit the optional convenience accessors alongside the constants.
Declaration
[Tooltip("Emit convenience accessors alongside the constants.")]
public bool EmitAccessors
Field Value
| Type | Description |
|---|---|
| bool |
GenerateOnSave
Whether saving the asset regenerates the constants file.
Declaration
[Tooltip("Regenerate on save. Off by default: writing a C# file triggers a domain reload, which drops the editor's undo history.")]
public bool GenerateOnSave
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Off by default. Writing a C# file under Assets compiles, and compiling
reloads the domain, which drops the editor's undo history. Generation is therefore
opt-in, and only a save that actually changes an identifier pays the cost, because
an unchanged generate writes nothing at all.
IsEnabled
Whether constants generation is configured for this asset at all.
Declaration
[Tooltip("Whether constants generation is configured for this asset.")]
public bool IsEnabled
Field Value
| Type | Description |
|---|---|
| bool |
Namespace
Namespace for the generated type, or empty to take the project's root namespace.
Declaration
[Tooltip("Namespace for the generated type. Leave empty to use the project's root namespace.")]
public string Namespace
Field Value
| Type | Description |
|---|---|
| string |
OutputPath
Project-relative output path, or empty to resolve one beside the action asset.
Declaration
[Tooltip("Project-relative path of the generated file. Leave empty to write beside the action asset.")]
public string OutputPath
Field Value
| Type | Description |
|---|---|
| string |
Methods
DeriveOutputPath(string, string)
Builds the default output path for an action asset, beside the asset itself.
Declaration
public static string DeriveOutputPath(string actionAssetPath, string className)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionAssetPath | Project-relative path of the action asset. |
| string | className | The resolved type name. |
Returns
| Type | Description |
|---|---|
| string | A project-relative path ending in |
Resolve(string, string)
Fills in whatever the author left blank, without writing anything back.
Declaration
public InputCodegenSettings Resolve(string actionAssetPath, string rootNamespace)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionAssetPath | Project-relative path of the action asset. |
| string | rootNamespace | The project's root namespace, or |
Returns
| Type | Description |
|---|---|
| InputCodegenSettings | A copy with every blank field resolved where a default exists. |
Remarks
One resolution point for the whole feature, so the panel's placeholder text and the generator's output cannot disagree about where a file will land. The namespace has no derived fallback on purpose: emitting into the global namespace is a poor thing to hand somebody, so an unresolvable namespace comes back empty and the caller refuses to generate until one is supplied.