NodeHandle
A handle to a GameObject in a scene definition. Chain calls to configure it and nest children.
public sealed class NodeHandle : SceneObjectHandleCompile-time scaffolding only — SceneBuilder parses the source text to build the scene, so these methods return handles for chaining but perform no work at runtime.
Members
Nonestaticfield
public static readonly NodeHandle NoneAssign this to a reference field to clear it, leaving the slot empty in the scene.
Selfstaticfield
public static readonly NodeHandle SelfAssign this to a reference field to point it at the GameObject the component is on — a Button's target graphic on its own Image, for example. It needs no variable, so it is legal inside the statement that declares the node.
Addmethod2 overloads
public NodeHandle Add(string name)Add a child GameObject.
public NodeHandle Add(string name, Action<NodeHandle> configure)Add a child GameObject and configure it in a closure.
Transformmethod
public NodeHandle Transform((float x, float y, float z)? pos = null, (float x, float y, float z)? rot = null, (float x, float y, float z)? scale = null)Set the local transform. Rotation is authored in Euler degrees.
RectTransformmethod
public NodeHandle RectTransform((float x, float y)? anchoredPos = null, (float x, float y)? sizeDelta = null, (float x, float y)? anchorMin = null, (float x, float y)? anchorMax = null, (float x, float y)? pivot = null)Set the UI layout (RectTransform). Presence of this call marks the node as a RectTransform node; omitted arguments stay at Unity's RectTransform defaults.
FitSizemethod2 overloads
public NodeHandle FitSize(float? width = null, float? height = null, float? depth = null)Aspect-locked world size: exactly one of width/height/ depth drives the size, aspect preserved on the other two axes.
public NodeHandle FitSize((float x, float y, float z) size)Explicit per-axis world size (non-uniform allowed).
SurfaceSnapmethod
public NodeHandle SurfaceSnap(bool up = false, bool down = false, bool left = false, bool right = false, bool forward = false, bool back = false, SceneObjectHandle target = null)Snap to a surface: at most one horizontal (left/right), one vertical (up/down), and one depth (forward/back) axis, with an optional explicit target override (skips the raycast/fallback scan). The target is any scene object handle — a GameObject or a prefab instance root.
Betweenmethod
public NodeHandle Between(SceneObjectHandle from, SceneObjectHandle to, float fraction, Between.Axis axis, SceneObjectHandle alongOrientationOf = null)Single-axis corridor placement: lands this object's bounds flush against from at fraction 0 and flush against to at fraction 1, moving only along axis. fraction is unclamped, so a value outside [0, 1] places past the respective anchor. axis is a world direction by default, or the matching local axis of alongOrientationOf when given, so placement can follow a tilted reference. Which anchor owns the fraction-0 end is fixed by argument order (from), not by which anchor sits at the higher world coordinate. Hierarchy-independent — anchors and self may live under unrelated parents. Chaining more than two Between calls into a longer anchor cycle is undefined: each evaluates independently and the last one to run wins.
Tagmethod
public NodeHandle Tag(string tag)Set the GameObject tag.
Layermethod
public NodeHandle Layer(int layer)Set the GameObject layer.
Activemethod
public NodeHandle Active(bool active)Set the active state.
Staticmethod
public NodeHandle Static(bool value = true)Mark the GameObject static.
Idmethod
public NodeHandle Id(string id)Assign an explicit, stable logical id (otherwise one is derived).
Instancemethod2 overloads
public InstanceHandle Instance(string assetPath)Instantiate a prefab instance nested under this GameObject, from assetPath (a .prefab or an imported model such as a .fbx). The path is authoring-time convenience only — the GUID is authoritative and stored in the sidecar; two calls with the same path produce two distinct instances.
public InstanceHandle<TRef> Instance<TRef>(TRef prefab) where TRef : PrefabRefInstantiate a prefab instance nested under this GameObject from a generated typed ref (e.g. Prefabs.Gun). Returns a typed handle so nested targets can be addressed via a compiler-checked selector (.On(t => t.Turret.Barrel, ...)) and overrides authored at existing-vocabulary depth (the instance root and its direct children).
Componentmethod2 overloads
public NodeHandle Component<T>()Attach a component of type T with no field overrides.
public NodeHandle Component<T>(Action<ComponentHandle<T>> configure)Attach a component of type T and set its serialized fields in a closure — c.Set("m_Mass", 5f) (serialized path) or c.Set(r => r.mass, 5f) (typed member selector).
Refmethod
public ComponentRef<T> Ref<T>(int ordinal = 0)Capture a reference to a component already added to this GameObject, to pass as a UnityEvent listener target. ordinal selects among several components of the same type on this GameObject (0 = the first).