Table of Contents

Namespace Velvet.Experimental

Classes

VBuilder

EXPERIMENTAL — PoC. Object/collection-initializer authoring surface that lets a V.* tree be written in a declarative nested-brace form while keeping full IDE completion and requiring no IDE plugin.

This is a thin ergonomic layer: a builder never reaches the Reconciler. Each builder is converted to a plain VNode via Build() (invoked by the implicit VBuilder -> VNode conversion), delegating to the existing V.* factories so all parsing / pooling semantics are reused.

Why initializers (C# 6/7) and not collection expressions (C# 12): Unity 6.3 defaults to C# 9 and does not officially support newer language versions; collection expressions [...] would force every consumer of the redistributed UPM package to swap their Roslyn compiler. Object/collection initializers compile on stock Unity, so this layer needs no toolchain change.

VNode Render()
{
    var (count, setCount) = UseState(0);
    return new VDiv("flex flex-col items-center gap-4 p-4")
    {
        new VLabel("text-2xl font-bold") { Text = $"Count: {count}" },
        new VButton("px-4 py-2 rounded bg-primary text-white")
        {
            Text = "Increment",
            OnClick = () => setCount(count + 1),
        },
    };
}
VButton

EXPERIMENTAL. Initializer-style builder for a button. Maps to Button(string?, string?, Action?, string?, string?, string?, bool?, StyleOverrides?, Func<VisualElement, Action>?, Func<VisualElement, VisualElement>?, string?, string?, string?, VNode?[]?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?).

VCustom<T>

EXPERIMENTAL. Initializer-style builder for a custom UnityEngine.UIElements.VisualElement subclass. Maps to V.Custom<T>(string, string, string, System.Func<UnityEngine.UIElements.VisualElement, System.Action>, VNode[]); children added via the collection initializer are kept.

VDiv

EXPERIMENTAL. Initializer-style builder for a generic container. Maps to Div(string?, string?, string?, FiberElementProps?, StyleOverrides?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?).

VImage

EXPERIMENTAL. Initializer-style builder for an image. Maps to Image(string?, string?, string?, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?). Images are leaves; children added via the collection initializer are ignored. The sprite/texture is typically set through Styles.

VLabel

EXPERIMENTAL. Initializer-style builder for a text label. Maps to Label(string?, string?, string?, string?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?). Labels are leaves; children added via the collection initializer are ignored.

VScrollView

EXPERIMENTAL. Initializer-style builder for a scrolling container. Maps to ScrollView(string?, string?, string?, ScrollerVisibility?, ScrollerVisibility?, TouchScrollBehavior?, Action<VisualElement>?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?); children added via the collection initializer become the scroll content.

VSlider

EXPERIMENTAL. Initializer-style builder for a slider. Maps to Slider(string?, float?, float?, float?, Action<float>?, string?, string?, bool?, Func<VisualElement, Action>?, Action<VisualElement>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?). Sliders are leaves; children added via the collection initializer are ignored.

VTextField

EXPERIMENTAL. Initializer-style builder for a text field. Maps to TextField(string?, string?, Action<string>?, string?, string?, string?, bool?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?). Text fields are leaves; children added via the collection initializer are ignored.

VToggle

EXPERIMENTAL. Initializer-style builder for a toggle. Maps to Toggle(string?, bool?, Action<bool>?, string?, string?, string?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?). Toggles are leaves; children added via the collection initializer are ignored.