This package provides extensions for Meta XR SDK, including the ability to create custom Building Blocks that appear in the Meta XR SDK Building Blocks panel.
- Custom Building Blocks: Create custom Building Blocks that integrate seamlessly with Meta XR SDK
- Easy Creation: Create Building Block assets with a simple context menu
- Automatic Integration: Custom blocks automatically appear in the Building Blocks window alongside Meta's official blocks
- Management Window: View and manage all your custom Building Blocks in one place
- Automatic Injection: Custom blocks are automatically injected into the Building Blocks registry
- UIToolkit Integration: Additional UIToolkit-related Building Blocks and scripts (see UIToolkit section)
- Context Menu Method:
- In the Project window, right-click where you want to create the block
- Select
Create > Meta > Create Building Block - A new
CustomBlockDataasset will be created - Configure the block by assigning a prefab, setting the name, description, thumbnail, and other properties
Open the management window:
- Go to
Meta > Building Blocks > Manage Building Blocks
In the management window you can:
- View all custom Building Blocks with thumbnails
- Click on a block to select it and view its details in the Inspector
- See block IDs, names, and descriptions
If your custom blocks don't appear in the Building Blocks window:
- Go to
Meta > Building Blocks > Refresh Building Blocks - This will force a refresh of the Building Blocks registry
Once created and configured, your custom Building Blocks will automatically appear in the Meta XR SDK Building Blocks window:
- Open the Building Blocks window (usually accessible from the Meta XR SDK status menu)
- Your custom blocks will be displayed alongside Meta's official blocks
- Click on a block to install it into your scene
-
BlockData Assets: Each Building Block is represented by a
CustomBlockDataScriptableObject asset. When created via the context menu, the asset is created in the currently selected folder. When created programmatically viaCustomBlockDataCreator, blocks are stored inAssets/Tools/BuildingBlocks/BlockData/by default (created automatically if needed). -
Prefab Setup: When using the
CustomBlockDataCreatorAPI (available in code), the system automatically:- Adds a
BuildingBlockcomponent to your prefab - Sets the
blockIdto link the prefab to its BlockData - Handles prefab naming (removes
[BuildingBlock]prefix if present)
- Adds a
-
Automatic Discovery: The
CustomBlockDataInjectorsystem automatically discovers allCustomBlockDataassets in your project and injects them into the Meta XR SDK Building Blocks registry. -
Tag Validation: The
TagValidationServicevalidates tags against Meta SDK's valid tag names. Invalid tags (including "Internal", "Hidden", and unrecognized tags) are automatically removed from blocks.
This package includes UIToolkit integration with:
- UIToolkit Building Block (prefab and asset)
- Various UIToolkit interaction scripts for XR input
- Sample scenes demonstrating UIToolkit usage
See the UIToolkit folder for more details and examples.
To subscribe to button clicks and other interactive element events in UI Toolkit, use the standard UI Toolkit event system:
// Get reference to your button
var root = uiDocument.rootVisualElement;
var button = root.Q<Button>("MyButton");
// Subscribe to click event (Method 1 - recommended)
button.clicked += OnButtonClicked;
// Or use RegisterCallback (Method 2)
button.RegisterCallback<ClickEvent>(OnButtonClickedEvent);
// Handler methods
private void OnButtonClicked()
{
Debug.Log("Button clicked!");
}
private void OnButtonClickedEvent(ClickEvent evt)
{
Debug.Log($"Button clicked at position {evt.position}");
}
// Don't forget to unsubscribe!
private void OnDisable()
{
button.clicked -= OnButtonClicked;
button.UnregisterCallback<ClickEvent>(OnButtonClickedEvent);
}