Class AchievementConditionEditContext
What the condition tree drawer needs from whoever is hosting it: the asset to mark dirty, who to tell once the tree changed, how to ask the author before something is thrown away, and how to fold several serialized writes into one undo step.
Inherited Members
Namespace: Serenity.Achievements.Infrastructure.Editor
Assembly: Serenity.UnityAchievements.Infrastructure.Editor.dll
Syntax
public sealed class AchievementConditionEditContext
Remarks
One object rather than four parameters threaded through a dozen drawing methods, and the seam that makes the writes testable: a test hands in its own confirmation and its own undo grouping instead of the editor's, so neither a modal dialog nor Unity's global undo stack has to be involved to prove the writer asked and grouped.
NotifyTreeChanged() exists because every write applies its own serialized changes.
A host watching only its own ApplyModifiedProperties never sees them, which is how an
inspector ends up showing findings about a tree the author already fixed.
Constructors
AchievementConditionEditContext(Object, Action, Func<string, string, bool>, Func<string, IDisposable>)
Creates the context a host hands to the drawer.
Declaration
public AchievementConditionEditContext(Object undoTarget, Action onTreeChanged = null, Func<string, string, bool> confirm = null, Func<string, IDisposable> beginUndoGroup = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | undoTarget | The asset edits are marked dirty against. May be |
| Action | onTreeChanged | Told after every successful write. May be |
| Func<string, string, bool> | confirm | Asks the author a yes/no question. Defaults to a modal dialog. |
| Func<string, IDisposable> | beginUndoGroup | Opens a named undo group. Defaults to Unity's own. |
Fields
CancelButtonLabel
The caption of the button that calls it off.
Declaration
public const string CancelButtonLabel = "Cancel"
Field Value
| Type | Description |
|---|---|
| string |
ConfirmButtonLabel
The caption of the button that goes ahead with a destructive replacement.
Declaration
public const string ConfirmButtonLabel = "Replace"
Field Value
| Type | Description |
|---|---|
| string |
Properties
UndoTarget
Declaration
public Object UndoTarget { get; }
Property Value
| Type | Description |
|---|---|
| Object | The asset edits are marked dirty against. |
Methods
BeginUndoGroup(string)
Opens an undo group that collapses everything written inside it into one step.
Declaration
public IDisposable BeginUndoGroup(string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The name the undo entry is listed under. |
Returns
| Type | Description |
|---|---|
| IDisposable | The scope to dispose once the writes are done. |
Confirm(string, string)
Asks the author to confirm something that cannot be undone by not doing it.
Declaration
public bool Confirm(string title, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The question's heading. |
| string | message | The question. |
Returns
| Type | Description |
|---|---|
| bool | True when the author agreed. |
NotifyTreeChanged()
Marks the asset dirty and tells the host the tree is no longer what it last read.
Declaration
public void NotifyTreeChanged()