Class ScyllaCopyMenu
A button that offers the same value in several text formats and copies the chosen one.
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public class ScyllaCopyMenu : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
Formats are registered rather than fixed, and each is a producer called at click time, so the menu always copies the current value without anyone having to push updates into it. That is the whole difference from writing a copy button by hand: the value and the formatting stay with the caller, and only the menu and clipboard plumbing live here.
Built on UnityEngine.UIElements.GenericDropdownMenu rather than the IMGUI
UnityEditor.GenericMenu, matching the UI Toolkit mandate and the precedent set
by the configuration export button.
Constructors
ScyllaCopyMenu(string)
Initializes a copy menu.
Declaration
public ScyllaCopyMenu(string label = "Copy")
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The button label. |
Properties
FormatCount
Gets how many formats are registered.
Declaration
public int FormatCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
AddFormat(string, Func<string>)
Registers a format, appended to the end of the menu.
Declaration
public void AddFormat(string label, Func<string> producer)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The menu entry label. |
| Func<string> | producer | Produces the text to copy. Called when the entry is chosen, not when it is registered, so it always sees the current value. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the label is |
| ArgumentNullException | Thrown when the producer is |
ClearFormats()
Removes every registered format.
Declaration
public void ClearFormats()
SetLabel(string)
Sets the button's label.
Declaration
public void SetLabel(string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The new label. |
Events
Copied
Raised after a format has been copied, carrying the text placed on the clipboard.
Declaration
public event Action<string> Copied
Event Type
| Type | Description |
|---|---|
| Action<string> |
Remarks
Callers use this to show a transient confirmation. The copy has already happened by the time it fires.