Scripting API

Scripting API

PrefabStage

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

A prefab opened to be edited on its own, or a model's to be looked at: built from its file into a scene of its own while the scene that was open is set aside as a draft, written back to its file from there, and closed, the scene given back.

public static class PrefabStage

Remarks

Built as a scene is, by the same pieces (SceneFile.Apply): its own entities as its file says them, and an instance of each prefab it holds, so what is written back is the file it was, its instances references still.

The scene set aside is a draft meanwhile (World.SetSceneDraft): still loaded, with its changes, but drawn, picked and met by no system, so the prefab's entities are all there is to see. Its instances of the prefab are brought up to date as any are once its file is written.

Methods

Open

public static SceneId Open(World world, string path, AssetDatabase database, IPrefabSource prefabs, SceneId setAside)

Builds the prefab at path under the asset root — a .prefab, or a model, whose prefab its import made — into a new scene named as its file, and makes setAside a draft.

Parameters

  • world: The world to build it in.
  • path: The prefab or the model, under the asset root.
  • database: What every file under the asset root is called, its root where the prefab is.
  • prefabs: Where the prefabs it holds instances of are read.
  • setAside: The scene that was open, a draft until PrefabStage.Close.

Returns The scene its entities are in.

Exceptions

  • InvalidOperationException: The prefab could not be read: not in the project, not imported, or not a prefab this build reads.

Save

public static SceneCapture Save(World world, SceneId scene, string path, AssetDatabase database, IPrefabSource prefabs, SceneWriting writing)

Writes the prefab open in scene to path, as a scene is written.

Parameters

  • world: The world it is in.
  • scene: The scene its entities are in.
  • path: Where to write, on the ordinary filesystem.
  • database: What every file under the asset root is called.
  • prefabs: Each prefab it holds, as its instances were built of it.
  • writing: How the project writes its scenes, which its prefabs are written as.

Returns What was written.

Close

public static void Close(World world, SceneId scene, SceneId setAside)

Takes the prefab open in scene out of the world, and makes setAside a scene again.

Parameters

  • world
  • scene
  • setAside