Table of Contents

Method Anchored

Namespace
Velvet
Assembly
Velvet.Docs.dll

Anchored(Transform?, Camera?, Vector2?, bool, bool, LayerMask?, float?, string?, string?, string?, FiberElementProps?, StyleOverrides?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Screen-space element that tracks a 3D scene Transform's projected position every frame (the default screen-space projection mode). This is ordinary 2D UI with no inherent scene depth (unlike WorldSpace(Vector3, Quaternion?, Vector2?, VNode?[]?, string?, PanelFocusOrder), which renders content INTO the 3D scene and is occluded by it for free) — occlude opts into an explicit physics stand-in for that test. Forces position: absolute inline (dynamic left/top positioning has no other way to work; see AnchoredDriver.Attach) — pass layout classes for everything else.

public static ElementNode Anchored(Transform? target, Camera? camera = null, Vector2? offset = null, bool hideWhenBehindCamera = true, bool occlude = false, LayerMask? occludeLayerMask = null, float? distanceFactor = null, string? className = null, string? key = null, string? name = null, FiberElementProps? props = null, StyleOverrides? styles = null, Func<VisualElement, Action>? refCallback = null, VNode?[]? children = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, IReadOnlyDictionary<string, string>? data = null, IReadOnlyDictionary<string, string>? aria = null)

Parameters

target Transform

The Transform this element's screen position tracks. Null (or a Transform destroyed later) mounts an inert, hidden (display: none) element until a live target is supplied — matching SceneView(Camera?, string?, string?, string?, float, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)/Particles(ParticleSystem?, string?, string?, string?, PlayTrigger, float, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)'s own null-tolerant convention, since a component holding a Transform in state can have it destroyed by unrelated game logic between renders.

camera Camera

The camera to project through. Null resolves to UnityEngine.Camera.main on every tick, so a scene's active camera can change without re-supplying this.

offset Vector2?

Pixel offset applied after projection (e.g. to center a label on the point).

hideWhenBehindCamera bool

When true (default), the element is hidden (display: none) while target is behind the camera rather than jumping to a wrong on-screen spot.

occlude bool

When true, a solid (non-trigger) collider between the camera and target hides the element — an extra physics query every tick, so it is off by default rather than a standing cost every consumer pays. A target whose own collider sits on occludeLayerMask will typically occlude itself; scope the mask to scene geometry that excludes it.

occludeLayerMask LayerMask?

Which colliders count as occluders when occlude is true. Null (default) resolves to UnityEngine.Physics.DefaultRaycastLayers.

distanceFactor float?

When set, scales the element by this value divided by its current distance to the camera, faking perspective size falloff for otherwise-flat screen-space content. Null (default) leaves the element unscaled and never touches style.scale, so it composes with a scale-* class or a Motion scale variant on the same element; a non-null value OWNS that style slot every tick instead and will fight either of those for it. Must be positive when supplied.

className string
key string
name string
props FiberElementProps
styles StyleOverrides
refCallback Func<VisualElement, Action>
children VNode[]
whileHoverClass string
whileTapClass string
whileFocusClass string
data IReadOnlyDictionary<string, string>
aria IReadOnlyDictionary<string, string>

Returns

ElementNode

The created ElementNode.

Exceptions

ArgumentOutOfRangeException

distanceFactor is <= 0, NaN, or positive infinity.