Get RAPTOR

RaptorSuiteHierarchyDrag.NestRules

Registers module rules for Hierarchy drops.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0

Within each NestSlot, rules are asked by order, then in registration order. The first rule that returns true decides the drop, and later rules are not asked. When no rule returns true, the Hierarchy's built-in rules decide. A rule that throws is logged once per id and treated as returning false. A domain reload clears the rules, and [InitializeOnLoad] registrations run again.

public static class NestRules

Properties

Count

public static int Count { get; }

The number of registered rules.

Ids

public static IReadOnlyList<string> Ids { get; }

A snapshot of every rule id, in the order rules are asked across both slots.

Version

public static int Version { get; }

Incremented on every change.

Methods

IsRegistered

public static bool IsRegistered(string id)

Whether a rule with this id is registered.

ParameterTypeDescription
idstringThe rule's stable id.

Returns: True when registered.

Register

public static bool Register(string id, NestRule rule, NestSlot slot = NestSlot.First, int order = 0)

Adds a rule in slot. Throws on a blank id, a null rule or an unknown slot.

ParameterTypeDefaultDescription
idstringThe rule's stable id.
ruleNestRuleDecides a drop.
slotNestSlotNestSlot.FirstThe slot the rule runs in.
orderint0Lower runs first; ties keep registration order.

Returns: False when the id is already registered. The existing rule is kept.

Call from an [InitializeOnLoad] static constructor on the main thread.

TryGetSlot

public static bool TryGetSlot(string id, out NestSlot slot)

Gets the slot a rule was registered in.

ParameterTypeDescription
idstringThe rule's stable id.
slotout NestSlotThe rule's slot.

Returns: False when the id is not registered.