RaptorModelPlacement
Free spots and free names for a new model.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, since 0.1.0 |
public static class RaptorModelPlacementFields
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.
| Parameter | Type | Description |
|---|---|---|
footprint | Rect | The model-local x/z footprint. |
start | Vector2 | Where the root lands first. |
step | float | The distance between tries. |
occupied | IList<Rect> | Taken world x/z rects. |
tries | int | How many spots to try. |
found | out bool | False 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.
| Parameter | Type | Description |
|---|---|---|
name | string | The 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.
| Parameter | Type | Description |
|---|---|---|
name | string | The name. |
scope | string | The 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.
| Parameter | Type | Description |
|---|---|---|
name | string | The 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.
| Parameter | Type | Description |
|---|---|---|
name | string | The name. |
scope | string | The 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.
Related types
- RaptorModelNameReservers: Lets a module reserve model names.