Get RAPTOR

RaptorModelStore

RAPTOR's built-in model store, used when no model provider fills the RaptorModelStorageSlots slots.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0

A model provider replaces whole actions but can call the low-level helpers here, which the built-in store also uses.

public static class RaptorModelStore

Fields

NoProvider

public const string NoProvider;

The refusal message shown when the project is set to "Provider only" and no provider fills the action.

ProviderOnlyKey

public const string ProviderOnlyKey;

The project settings key for the Model storage setting. The value is true for Provider only. A missing key means Built-in.

Properties

ModelsRoot

public static string ModelsRoot { get; }

The folder for saved models, stored as <ModelsRoot>/<name>/<name>.prefab. Same as RaptorModelStorageSlots.ModelsRoot.

ProviderOnly

public static bool ProviderOnly { get; set; }

Whether the Model storage setting is "Provider only". When true, an empty RaptorModelStorageSlots slot refuses its action instead of using the built-in store. Read from the project settings, and false when the key is missing. Setting it changes the in-memory value only. Call RaptorProjectSettings.Save to persist it.

Methods

ConfirmReplace

public static bool ConfirmReplace(string name, out string notice)

Asks the user before a save replaces a different model saved under name. A model provider's save calls this after finding that the saved model is a different one. In batch mode, returns false without asking.

ParameterTypeDescription
namestringThe model's name.
noticeout stringA short message for the user, or null when the user cancelled.

Returns: True when the save should go ahead and replace the saved model.

Load

public static GameObject Load(string prefabPath, out string notice)

Loads the saved model at prefabPath as one undo step. The model is unpacked, placed at the origin and selected. If a room with that name is already in the scene, that room is selected instead.

ParameterTypeDescription
prefabPathstringThe saved prefab.
noticeout stringA short message for the user, or null.

Returns: The scene object, or null.

PrefabPath

public static string PrefabPath(string root, string name)

Gets the saved prefab path of name under root.

ParameterTypeDescription
rootstringThe models folder.
namestringThe model's name.

Returns: The path.

Rename

public static bool Rename(string oldName, string newName, out string notice)

Renames a saved or loaded room everywhere its name is used as a key: the saved prefab and its folder, the baked meshes (Baked/<name>_*) and their folder, and the scene copy. All moves are checked before any is made. If a move still fails, the earlier moves are reverted. The prefab keeps its GUID, so it stays in its category. The scene copy's undo history is cleared, because undoing to the old name would separate the room from its renamed saved source.

ParameterTypeDescription
oldNamestringThe current name.
newNamestringThe new name.
noticeout stringA short message for the user, or null.

Returns: False when refused.

RenameRefusal

public static string RenameRefusal(string oldName, string newName)

Gets a short reason why oldName cannot be renamed to newName, or null when it can.

ParameterTypeDescription
oldNamestringThe current name.
newNamestringThe new name.

Returns: The reason, or null when it can.

RequireProvider

public static void RequireProvider()

Call once from a model provider's load hook. If the Model storage setting has never been set, this sets the project to "Provider only" and saves it. After that, if the provider's code fails to load, Save and Load are refused instead of falling back to the built-in store, which lacks the provider's steps. A choice already made on the settings page is kept. Runs on EditorApplication.delayCall, waits until Play mode ends, and does nothing in batch mode. Safe to call more than once.

Save

public static bool Save(RaptorModel model, out string notice)

Saves model to ModelsRoot. Bakes the model if it is stale, verifies and heals its colliders, writes the prefab and checks it on disk. Asks first if a different model is already saved under this name. If the user cancels a dialog, returns false and leaves notice null.

ParameterTypeDescription
modelRaptorModelThe model.
noticeout stringA short message for the user, or null.

Returns: False when not saved.

SaveAndUnload

public static bool SaveAndUnload(RaptorModel model, out string notice)

Saves the model, then removes the scene copy. The removal cannot be undone. If the save fails, the scene copy is kept.

ParameterTypeDescription
modelRaptorModelThe model.
noticeout stringA short message for the user, or null.

Returns: False when not saved.

VerifyOrHealColliders

public static bool VerifyOrHealColliders(GameObject root, string context)

Checks that every baked mesh collider under the model has its mesh, and restores any missing mesh from the canonical mesh. A saved model without collider meshes renders but has no collision.

ParameterTypeDescription
rootGameObjectThe model's root object.
contextstringA label for the log.

Returns: True when every collider has its mesh.

  • RaptorModelStorageSlots: Slots a model provider fills to replace Save, Save & unload, Load and Rename.
  • RaptorProjectSettings: RAPTOR's per-project settings file and the section registry for Project Settings → RAPTOR.