Layout
Lines up the entity’s children in a list or a grid, so nothing has to place them: a board of offer cards, a list of quest rows, a shop’s shelf. They take their places in hierarchy order from the top left corner of its Size, whatever their own positions: one spawned into it (Game.Spawn(“Card”, board)) goes after the last, and when one is destroyed or hidden the rest close up. With Clip what doesn’t fit is cut off at its edges and the mouse wheel scrolls it. With Reorderable the player drags them into a new order: a queue, a build list. With Slide they slide to their new places rather than jumping there.
A child takes the room of its Button’s clickable area, its Sprite’s size or its own Layout’s, whichever is biggest, times its scale; a child with only text takes what its letters are guessed to. Set CellSize to give every child the same room. Put the background on the layout’s own entity: every child showing is placed. In the Scene view children are put in place as you edit; a child’s own position is overwritten.
Works with: Sprite (a background)
Needed by: ControlsList, TogglesList
Changes how its entity is drawn (a tint, a shake or drawing it on top).
In a network game, each machine keeps its own entity with this on it: it isn’t sent.
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
direction: one of Vertical, Horizontal, Grid = “Vertical”. Which way the children go: down a list, across a row, or in a grid of Columns. (Field: one of its values.)columns: a whole number = 3. How many children a grid row holds before the next row starts. (Only used when direction is Grid.) (Field: a number.)spacing: a number = 0.2. The gap between one child and the next, in world units. (Field: a number.)padding: a number = 0. The space between its edges and the children, in world units. (Field: a number.)size: [x, y] = [6,4]. Its area, centered on the entity, in world units before the transform’s scale: the children start at its top left corner (inside the Padding), and with Clip they’re cut off at its edges. Without Clip children that don’t fit go on past it. (A rectangle’s size, around the entity, in its own units before its scale: with Resize handles the Scene view puts handles on its edges and corners to drag.) (Field: a vector.)cellSize: [x, y] = [0,0]. The room every child takes, in world units: (2, 3) for cards that size. 0 (either way) measures each child: its Button’s clickable area, its Sprite’s size or its own Layout’s, whichever is biggest, times its scale. (Field: a vector.)clip: true or false = false. Cut the children off at the edges of its Size, and scroll them with the mouse wheel over it when there are more than fit (or from a script with Scroll). (Field: on or off.)
Reordering
Section titled “Reordering”reorderable: true or false = false. Let the player put its children in a new order: press on one and drag it along the list (or about the grid), the others sliding to make room where it would land, and let go to put it there, which raises Reordered. A press that doesn’t move still clicks a Button on it; Esc, or letting go outside it, puts the row back. Dragged near the end of one that Clips, it scrolls. With keys or a controller, GrabAction lifts the row of the button picked, the arrows move it and a second press (or Enter or A) puts it down. (Field: on or off.)grabAction: text = “Interact”. The input action that lifts the picked button’s row to move it with the arrows (or the D-pad), and puts it down again, e.g. “Interact” (E or the gamepad’s Y). Empty leaves reordering to the mouse. (Only used when reorderable is on.) (Names an input action.) (Field: a name.)slide: true or false = false. While the game runs, its children slide to their new places rather than jumping there, over SlideTime: the rest closing up when one is destroyed or hidden, making room for one added, moving as they’re put in a new order or scrolled. One that’s just been added (or shown) is put in its place at once. (Field: on or off.)slideTime: a number = 0.1. Seconds its children take to slide into new places (with Slide), and, while it’s Reorderable, the other rows out of the way and a let-go row into its place. 0 jumps. (Field: a number.)saveOrderAs: text = null. A name in Game.SaveData to keep the order in: the rows’ names, separated by commas, saved as the player changes it and put back whenever rows with those names are in it (rows made again from a table, a game loaded). Rows it doesn’t name keep their places. Empty keeps no order. Give each row its own name for it to work. (Only used when reorderable is on.) (Names a name in the save data: this entity’s own, which other fields can name.) (Field: a name.)reorderMessage: text = null. A message sent with Game.Send when a row is put in a new place, with the row as its data. (Only used when reorderable is on.) (Names a message.) (Field: a name.)
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
scroll: a number. How far it’s scrolled, in world units from the start (down a list or grid, along a row), from 0 to MostScroll. The mouse wheel changes it while Clip is on; scripts can set it.mostScroll: a number. How far it can scroll: how much more the children take up than there’s room for. 0 when they all fit.scrollStep: a number. How far one turn of the mouse wheel scrolls it: a row of children.held: an entity: its name, id or path. The row being dragged or moved with keys, or null.
Scripts use it as Layout: its methods, events and values that aren’t saved with the scene.