Scripting API
Scripting API
LayerSettings
Class in Abyss.Core, from Abyss.Core.
A project's 32 layers by name: settings/layers.json beside the game's assets, which Project Settings' Tags and Layers page lays out. An entity is on one of them (World.SetLayer), Default unless it says otherwise, and a camera draws those its culling mask has (World.SetCullingMask).
public sealed class LayerSettingsRemarks
Layer 0 is Default, always and by that name; the other 31 are the project's to name, and one with no name is there all the same, unnamed. Two layers are never called the same, whatever their letters' case.
A game's code names a layer by a constant the build writes — Layers.Player, the layer's number — so a layer renamed or taken away is a compile error, not a name looked for and not found as the game plays; LayerSettings.CodeNames says what each is called.
Constructors
LayerSettings
public LayerSettings()A project's layers before it names any: Default, and 31 unnamed.
Methods
NameOf
public string? NameOf(int layer)What layer layer is called; null for one not named.
Parameters
layer
Exceptions
ArgumentOutOfRangeException: The number is not one of the 32.
IndexOf
public int IndexOf(string name)The number of the layer called name, whatever its letters' case; -1 for none.
Parameters
name
Named
public IEnumerable<(int Layer, string Name)> Named()Each named layer's number and name, Default first.
CodeNames
public IReadOnlyList<(int Layer, string Code)> CodeNames()What a game's code calls each named layer: Default, Player; see LayerSettings.
WhyNot
public string? WhyNot(int layer, string name)Why layer layer cannot be called name: Default is Default, a name is no longer than LayerSettings.LongestName and has a letter or a digit in it, and two layers are not called the same; null where it can. An empty name leaves the layer unnamed.
Parameters
layername
Exceptions
ArgumentOutOfRangeException: The number is not one of the 32.
Rename
public bool Rename(int layer, string name)Calls layer layer name, trimmed; an empty name leaves it unnamed.
Parameters
layername
Returns Whether that changed it.
Exceptions
ArgumentException: It cannot be called that (LayerSettings.WhyNot).
FileIn
public static string FileIn(string game)Where a game keeps it: settings/layers.json in its folder.
Parameters
game
Read
public static LayerSettings Read(string game)A game's layers; Default alone for one with no layers.json.
Parameters
game
Exceptions
FormatException: The file is not layers this build reads, saying why.IOException: The file is there and cannot be read.
Parse
public static LayerSettings Parse(string json)Layers from their text: {"abyssLayers": 1, "layers": [{"layer": 8, "name": "Player"}]}.
Parameters
json
Exceptions
FormatException: It is not layers this build reads, saying why.
ToJson
public string ToJson()The layers as their file holds them, the named ones but Default, in order.
Write
public void Write(string game)Writes the layers into a game's folder.
Parameters
game
Copy
public LayerSettings Copy()A copy, to change without changing this.
Constants
Count
public const int Count = 32How many layers a project has.
Default
public const int Default = 0The layer an entity is on unless it says otherwise, and what it is called.
DefaultName
public const string DefaultName = "Default"What layer 0 is called.
FileName
public const string FileName = "layers.json"The file, under the game's settings folder.
PathName
public const string PathName = "settings/layers.json"What it is called in a game's folder and in its pack: settings/layers.json.
CurrentVersion
public const int CurrentVersion = 1The version of the file this build writes, and the newest it reads.
LongestName
public const int LongestName = 64The longest a layer's name may be.
