Scripting API

Scripting API

BuildSettings

Class in Abyss.Core, from Abyss.Core.

What a build makes of a game: what it is called, the window it opens, and the scenes in it, the first of which it opens — settings/build.json in the game's folder, beside its assets.

public sealed class BuildSettings

Remarks

Kept in the project, beside the assets and not among them, as the settings of a whole game are: the Project panel does not list it, and nothing loads it as an asset. A build copies it into the game's pack, where the engine's player reads it before anything else.

Each scene by its identity as well as its path, as a material file names what it draws with, so a scene moved or renamed is still the one in the build.

Written and read by hand, as a scene file is, for the same two reasons: a serializer that reflects over properties does not survive the ahead-of-time compilation a built game is made with, and the file is a format that will outlive the class.

Properties

Product

public string Product { get; set; }

What the game is called: its window's title; empty for its assembly's name.

Width

public int Width { get; set; }

How wide its window opens, in logical pixels.

Height

public int Height { get; set; }

How tall its window opens, in logical pixels.

Scenes

public List<BuildScene> Scenes { get; }

The scenes in the build, in its order: the first ticked is the one the game opens.

FirstScene

public BuildScene? FirstScene { get; }

The scene a built game opens: the first one ticked; null for none.

Methods

FileIn

public static string FileIn(string game)

Where a game keeps its settings: settings/build.json in its folder.

Parameters

  • game: The game's folder, the one its assets are in.

Read

public static BuildSettings Read(string game)

A game's settings, from its folder; for a game with none, a build of nothing.

Parameters

  • game: The game's folder, the one its assets are in.

Exceptions

  • FormatException: The file is not settings this build reads.
  • IOException: The file is there and cannot be read.

Parse

public static BuildSettings Parse(string json)

Settings from their text.

Parameters

  • json

Exceptions

  • FormatException: It is not settings this build reads, saying why.

ToJson

public string ToJson()

The settings as their file holds them: only what differs from what a build assumes, and every scene.

Write

public void Write(string game)

Writes the settings into a game's folder, making its settings folder if it has none.

Parameters

  • game: The game's folder, the one its assets are in.

Resolved

public BuildSettings Resolved(AssetDatabase database)

The settings with each scene named by the path it is at now — found by its identity where it was moved — as a build packs them; one that is nowhere keeps the path it had.

Parameters

  • database: The game's assets.

Constants

FolderName

public const string FolderName = "settings"

The folder beside the assets a game keeps its settings in.

FileName

public const string FileName = "build.json"

The file, under BuildSettings.FolderName.

PathName

public const string PathName = "settings/build.json"

What it is called in a game's folder and in its pack: settings/build.json.

CurrentVersion

public const int CurrentVersion = 1

The version this build writes, and the newest it reads.

DefaultWidth

public const int DefaultWidth = 1280

The width a window opens at when nothing says otherwise.

DefaultHeight

public const int DefaultHeight = 720

The height a window opens at when nothing says otherwise.