Scripting API

Scripting API

PrefabFolder

Class in Abyss.Core.Scenes, from Abyss.Core.

Prefabs read out of the project folder, found by identity first and by path second.

public sealed class PrefabFolder : IPrefabSource

Remarks

The same resolution every other asset reference gets, and for the same reason: a prefab somebody moved into a different folder should not empty every scene that used it. The identity wins, the path is the fallback, and a reference with neither is a note.

A model is a prefab too, the one the editor made of its import and keeps in the cache beside the asset root (ModelPrefab), found by the model's identity as its meshes are. A model not imported yet has none, and says so.

Constructors

PrefabFolder

public PrefabFolder(AssetDatabase database, string? cache = null)

Reads prefabs from the folder a database describes.

Parameters

  • database: What every file under the asset root is called.
  • cache: Where the imports of its models are, its whole path; null for the cache folder beside the asset root, ModelImporter.CacheFolder.

Methods

Open

public SceneDocument? Open(AssetGuid id, string? path, out string why)

The document a reference names, or null with a reason it could not be read.

Parameters

  • id: The prefab's identity, which wins where it is known.
  • path: Where it was when the reference was written, which is the fallback.
  • why: Why nothing came back, in words for a note. Empty on success.

Each file is read once per source. A scene with twenty instances of one prefab is one read, which matters because expansion is recursive and a nested prefab would otherwise be re-read once per instance of every prefab above it. A source is made per load, so an edited prefab is picked up by the next one rather than being cached for the run.