Get RAPTOR

RaptorModelPlacement

Free spots and free names for a new model.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0
public static class RaptorModelPlacement

Fields

SpotGrid

public const float SpotGrid;

The search step is rounded up to a multiple of this, in metres.

SpotMargin

public const float SpotMargin;

The margin kept clear around a new model, in metres.

Methods

FreeSpot

public static Vector2 FreeSpot(Rect footprint, Vector2 start, float step, IList<Rect> occupied, int tries, out bool found)

Finds a free spot for a model's root. Tries start, then start + k·step along +X for k = 1 to tries - 1, and returns the first spot where footprint, grown by SpotMargin, overlaps none of the occupied rects. When no spot is free, returns the last one tried and sets found to false. Has no side effects.

ParameterTypeDescription
footprintRectThe model-local x/z footprint.
startVector2Where the root lands first.
stepfloatThe distance between tries.
occupiedIList<Rect>Taken world x/z rects.
triesintHow many spots to try.
foundout boolFalse when none was free.

Returns: The spot, or the last one tried when none is free.

NameRefusal

public static string NameRefusal(string name)

Gets the reason name cannot be used for a new model: "Name required", "Not a file name" or "Name taken". Returns null when the name can be used.

ParameterTypeDescription
namestringThe name.

Returns: The reason, or null.

NameRefusal

public static string NameRefusal(string name, string scope)

Same as NameRefusal, but also checks the reservers registered for scope.

ParameterTypeDescription
namestringThe name.
scopestringThe reservers' scope.

Returns: The reason, or null.

NameTaken

public static bool NameTaken(string name)

Whether name is used by a loaded model, a model's bake, export or lightmap-group assets (RaptorModelNames.IsTaken), a saved model in the Models library (<ModelsRoot>/<name>/), or an unscoped reserver (RaptorModelNameReservers). A null or empty name counts as taken. It searches the scene and assets, so call it when the name changes and avoid calling it on every repaint.

ParameterTypeDescription
namestringThe name.

Returns: True when used.

NameTaken

public static bool NameTaken(string name, string scope)

Same as NameTaken, but also checks the reservers registered for scope.

ParameterTypeDescription
namestringThe name.
scopestringThe reservers' scope.

Returns: True when used.

OccupiedFootprints

public static List<Rect> OccupiedFootprints()

Gets the x/z bounds of every loaded outermost model, for use with FreeSpot. The bounds include renderers, colliders and child positions, so an empty model with no renderers still has a footprint.

Returns: The footprints.