RaptorModelVariantNamers
The registered variant namers, tried in order until one names the copy.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, since 0.1.0 |
Namers are tried by order, then by registration order. When no namer names a copy, the variant is named "<stem> Variant 1", 2 and so on. The first registration of an id wins, and later ones do nothing. A namer that throws is logged once per id and skipped. The registry is editor-only and is cleared on domain reload, after which the registrants run again.
public static class RaptorModelVariantNamersProperties
Count
public static int Count { get; }The number of namers.
Ids
public static IReadOnlyList<string> Ids { get; }A snapshot of every namer id, in the order the namers are tried.
Version
public static int Version { get; }Increments on every change.
Methods
IsRegistered
public static bool IsRegistered(string id)Whether a namer with this id is registered.
| Parameter | Type | Description |
|---|---|---|
id | string | The namer's stable id. |
Returns: True when registered.
Register
public static bool Register(string id, IRaptorModelVariantNamer namer, int order = 0)Adds a namer. Returns false and keeps the existing namer when id is already registered. Throws when id is blank or namer is null.
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | The namer's stable id. | |
namer | IRaptorModelVariantNamer | The namer. | |
order | int | 0 | Lower values run first. Ties keep registration order. |
Returns: False when the id is taken.
Call from an [InitializeOnLoad] static constructor on the main thread.
TryName
public static bool TryName(string sourceName, Func<string, bool> taken, out string name)Gets a name for a copy of sourceName from the first namer that names it. A namer that returns an empty name is skipped.
| Parameter | Type | Description |
|---|---|---|
sourceName | string | The model being copied. |
taken | Func<string, bool> | Returns true when a name is in use. |
name | out string | The copy's name. |
Returns: False when no namer named the copy.
Related types
- IRaptorModelVariantNamer: A module's naming rule for variant copies (RaptorSuiteModelVariant.VariantName).