Extending
All code is in the AllInOneWorldBuilder (runtime) and AllInOneWorldBuilder.Editor (editor) namespaces, in the
assemblies AllInOneWorldBuilder.Runtime and AllInOneWorldBuilder.Editor. Both are auto-referenced, so your own
scripts can use them directly.
Surfaces #
SurfaceTag (runtime) carries a surface name on an object; the Prefab Builder adds it to placeable copies of ground
and road pieces. Read it from your game, the kit plays no sounds and assumes no footstep system:
using AllInOneWorldBuilder;
if (Physics.Raycast(foot.position, Vector3.down, out var hit, 0.5f) &&
SurfaceTag.TryGetSurface(hit, out var surface))
{
PlayFootstep(surface); // "Grass", "Asphalt", ... as named in the Settings
}
Implement ISurfaceSource on your own components to supply surface names another way; SurfaceTag.TryGetSurface
finds any ISurfaceSource on the object or above it.
Runtime components #
SurfaceTag/ISurfaceSource: above.LayerCullDistance: on a camera: stops it drawing one layer (the small-props layer scatter is on) past a distance. Uses Unity's per-layer cull distances; works in every render pipeline.ScatterChunk: marks a chunk of combined scatter (its group, cell, piece count). Plain data.WorldBuilderSpline: on a spline laid by the Spline mode: its points and layout settings, so it can be edited and laid again. Plain data; its pieces are its children.WorldBuilderMark: on what a tool made (street furniture, a closure): which tool and what for, so running the tool again replaces it. Plain data; remove it and the object is simply yours.SignText, text on a sign board: text, font (none shipped, Unity's built-in one otherwise), colour, fit, both sides. Plain data; the Prefab Builder lays a child text object from it.WorldBuilderFence: on a fence built by Dress > Fence: the objects it goes round, its margin and rectangle, so changing Margin builds it again. Data only.WorldBuilderClosure: on a closure built by Dress > Closures: its line and set-up, so it can be changed and built again. Plain data.PlayFromHere: where Check > Play started Play (HasSpot,Position,Rotation), for a game that places its own player: read it in your spawn code. Editor only: set just before Play starts, cleared when it ends, never set in a build.- The Sign Text shader (
All In One Prefab Builder/Sign Text): unlit text that's hidden behind what stands in front of it, in every render pipeline.
Data from code #
DataStore.ActiveRuleSet,DataStore.ActivePalette,DataStore.Kits(): the current data.Kit.Pieces: eachKitPiecehas its category, front side, measurements andLoadPrefab().KitService: create, re-scan, rename, merge, hide and remove kits;KitService.KitsChangedfires after each.PresetService: export and import presets from code (Export,ToJson,FromJson,Plan,Apply).RoadGrid,StreetDresser,ClosureBuilder,SignBuilder, the Dress tab's: a road's cells and edges, street furniture planned and placed along them, a closure planned and built at a road end, text laid on a sign board.LineLayout,FencePlanner,FillPlanner,SplineBuilder, the planning behind Row, Spline, Fence and Fill: plan a line of pieces along aLinePath, a fence round a rectangle, a fill's tiles and spread pieces, or lay aWorldBuilderSplineagain (plans are lists ofLinePlan: piece, pivot, rotation, box).
Your own modes and tabs #
Subclass WorldBuilderMode (public parameterless constructor) in any editor assembly: the window finds it. Its Tab
decides where it appears: one of WorldBuilderTabs (Move, Place, Physics, Dress, Fix, Check, Settings), or a name of your
own, which becomes an extra tab after Settings.
using AllInOneWorldBuilder.Editor;
using UnityEditor;
using UnityEngine;
public class SpawnPointsMode : WorldBuilderMode
{
public override string Tab => "My Game";
public override GUIContent Label => new GUIContent("Spawns", "Place and check spawn points.");
public override string Hint => "Click to add a spawn point.";
public override string Help => "Adds spawn points for my game.";
public override void OnPanelGUI(WorldBuilderWindow window)
{
EditorGUILayout.LabelField("Spawn tools go here.");
}
public override void OnSceneGUI(SceneView view)
{
// Scene view events while this mode is active.
}
}
Override OnActivate / OnDeactivate, OnBeforeSceneGUI (drawing before the camera renders), OnOverlayGUI (a few
quick controls in the overlay: its name and hint are shown for you), Order (position in the mode selector), ScrollPanel
and TakesSceneClicks (true if the mode takes Scene view clicks: Unity's transform tool is set aside while it's active,
and picking a Unity tool hands the Scene view back) as needed.
Events #
WorldBuilderEvents (editor) tells you when the tools change the scene:
Placed(GameObject placed, KitPiece piece): a piece was placed (piece is null for a prefab that isn't in a kit).Changed(GameObject target, string what): snapped, dropped to the ground…Removed(GameObject target): raised before a tool removes an object.
[InitializeOnLoadMethod]
static void Hook()
{
WorldBuilderEvents.Placed -= OnPlaced;
WorldBuilderEvents.Placed += OnPlaced;
}
static void OnPlaced(GameObject placed, KitPiece piece)
{
if (piece != null && piece.category == BuiltInCategories.Building) { /* add your own components */ }
}
Closure types and street furniture are data in the rule set (Settings > Rules). Validators and the play-from-here hook arrive with their tools in later versions.