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>?, FiberEventBinding[]?)

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. Among a WorldSpace(Vector3, Quaternion?, Vector2?, VNode?[]?, string?, PanelFocusOrder) panel's children it sits where the camera's ray to the target crosses that panel's plane. As drei's <Html> does, it renders a wrapper that owns the position, the hide and the distanceFactor scale, and puts the element carrying className, name, events, the ref and the children inside it; z-* classes stay on the wrapper, which is the out-of-flow element they stack.

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, FiberEventBinding[]? events = 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>?, FiberEventBinding[]?)/Particles(ParticleSystem?, string?, string?, string?, PlayTrigger, float, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?, FiberEventBinding[]?)'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. When false, it keeps following the target's projection there too.

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 the world height the camera sees at the target, as drei's distanceFactor does: 2 * tan(fov / 2) * distance for a perspective camera, 2 * orthographicSize for an orthographic one. Null (default) leaves the wrapper unscaled. The scale is the wrapper's, so a scale-* class or a Motion scale variant on the element inside composes with 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>
events FiberEventBinding[]

Event bindings applied to the element (Documentation~/react-migration.md owns the rule). The array is read and never written.

Returns

ElementNode

The created ElementNode.

Exceptions

ArgumentOutOfRangeException

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