Get RAPTOR

RaptorModelVariantNamers

The registered variant namers, tried in order until one names the copy.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, 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 RaptorModelVariantNamers

Properties

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.

ParameterTypeDescription
idstringThe 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.

ParameterTypeDefaultDescription
idstringThe namer's stable id.
namerIRaptorModelVariantNamerThe namer.
orderint0Lower 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.

ParameterTypeDescription
sourceNamestringThe model being copied.
takenFunc<string, bool>Returns true when a name is in use.
nameout stringThe copy's name.

Returns: False when no namer named the copy.