Class MenuDraft
One menu being authored in the Menu Manager wizard: a scratch UnityMenuSettingsDefinition
the author edits through the wizard's inspector GUIs before MenuCreator ever touches a
real asset. Mirrors CreateHudWindow's own scratch-instance pattern for a HUD element.
Implements
Inherited Members
Namespace: Serenity.Menu.Infrastructure.Editor.Builder
Assembly: Serenity.UnityMenu.Infrastructure.Editor.dll
Syntax
public sealed class MenuDraft : IDisposable
Remarks
UnityEngine.HideFlags.DontSave rather than UnityEngine.HideFlags.HideAndDontSave is deliberate:
CreateHudWindow documents that the latter also carries NotEditable, which greys out every
field in an inspector GUI drawn against the instance — exactly what SerializedObject here
exists for.
Fields
AssetName
File name (without extension) the created or updated asset will use.
Declaration
public string AssetName
Field Value
| Type | Description |
|---|---|
| string |
Properties
Definition
The scratch definition the wizard edits.
Declaration
public UnityMenuSettingsDefinition Definition { get; }
Property Value
| Type | Description |
|---|---|
| UnityMenuSettingsDefinition |
SerializedObject
A SerializedObject over Definition for the wizard's inspector GUIs, created on first use.
Declaration
public SerializedObject SerializedObject { get; }
Property Value
| Type | Description |
|---|---|
| SerializedObject |
SourceAsset
The real asset this draft was loaded from, or null when the draft describes a brand-new menu. MenuCreator updates this asset in place instead of creating a new one when set.
Declaration
public UnityMenuSettingsDefinition SourceAsset { get; }
Property Value
| Type | Description |
|---|---|
| UnityMenuSettingsDefinition |
Methods
CreateNew(string)
Starts a draft for a brand-new menu, seeded with defaultId.
Declaration
public static MenuDraft CreateNew(string defaultId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | defaultId | The id to seed the scratch definition and the asset name with. |
Returns
| Type | Description |
|---|---|
| MenuDraft |
Remarks
The seeded UnityMenuSettingsDefinition.Guid is the key a sibling draft's transition
option stores in its Value.Guid, so a target survives the sibling's id being renamed later in
the run; MenuCreator preserves a non-empty guid when it writes the asset, so what the
sibling stored is what lands on disk. Creating the same draft list twice would therefore yield two
assets carrying one guid — the wizard disposes its drafts when a run resets, so it never does.
Dispose()
Destroys the scratch instance. Safe to call more than once.
Declaration
public void Dispose()
FromExisting(UnityMenuSettingsDefinition)
Starts a draft loaded from an existing asset: every serialized field is copied onto the scratch instance, and SourceAsset keeps the reference so MenuCreator updates it in place rather than creating a new one. The asset's own guid is kept — a sibling that already targets this menu on disk keeps resolving it — and only seeded when the asset carries none.
Declaration
public static MenuDraft FromExisting(UnityMenuSettingsDefinition asset)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityMenuSettingsDefinition | asset | The existing menu asset to edit. |
Returns
| Type | Description |
|---|---|
| MenuDraft |