How to: Create a Custom User Representation
This guide explains step by step how to add a new user representation type to the HoloMIT SDK, combining:
- A new
UserRepresentationType - A handler implementing
IUserRepresentationHandler - Integration with pipelines through
RepresentationSetupContext.UserSourceType
1. Define the Representation Type
Create a static bootstrap class to store your new type:
using Holo.Core;
public static class MyCustomRepresentationBootstrap
{
public static readonly UserRepresentationType CUSTOM_HOLOGRAM =
UserRepresentationType.CreateAndRegister(
"CUSTOM_HOLOGRAM",
"Custom Hologram",
true);
}
2. Implement the Handler
Create a new class that implements IUserRepresentationHandler and configures your scene accordingly.
using Holo.Core;
using UnityEngine;
public class CustomHologramHandler : IUserRepresentationHandler
{
public void Setup(RepresentationSetupContext _context)
{
// Example: Ensure avatar is disabled for this representation
if (_context.PlayerManager.avatar != null)
{
_context.PlayerManager.avatar.SetActive(false);
}
// Example: Enable your custom hologram GameObject
if (_context.PlayerManager.TryGetComponent(out CustomHologramController _hologram))
{
_hologram.gameObject.SetActive(true);
// Add your code to activate or init your pipeline or components.
}
// Use CustomPayload for extra configs if needed
if (_context.CustomPayload is CustomHologramConfig _config)
{
// Apply configuration (quality, resolution, etc.)
// _hologram.ApplyConfig(_config);
}
}
}
This same pattern applies to any custom representation: enable/disable the correct objects and bind them to the appropriate pipeline.
3. Register the Handler
Bind your new handler to the representation type during initialization:
using Holo.Core;
public static class MyCustomRepresentationHandlersBootstrap
{
public static void RegisterHandlers()
{
RepresentationHandlerRegistry.Register(
MyCustomRepresentationBootstrap.CUSTOM_HOLOGRAM,
new CustomHologramHandler());
}
}
Call RegisterHandlers() from your game bootstrap (e.g. an initialization scene, or the HoloMIT integration entry point).
4. Applying the Representation at Runtime
When the player confirms their choice (e.g. in the lobby), resolve the type and call the handler:
public class PlayerRepresentationApplier : MonoBehaviour
{
[SerializeField]
private RepresentationSelector selector;
[SerializeField]
private PlayerManager playerManager;
[SerializeField]
private Player player;
public void ApplySelectedRepresentation()
{
var _type = selector.GetSelectedType();
if (_type == null)
{
Debug.LogWarning("No representation type selected or type not registered.");
return;
}
if (!RepresentationHandlerRegistry.TryGetHandler(_type, out var _handler))
{
Debug.LogWarning($"No handler registered for representation type '{_type}'.");
return;
}
var _context = new RepresentationSetupContext
{
Player = player,
PlayerManager = playerManager,
IsLocalPlayer = player.IsLocal,
IsPreview = false,
IsProducer = player.IsProducer,
IsConsumer = player.IsConsumer,
UserSourceType = playerManager.CurrentSourceType
};
_handler.Setup(_context);
}
}
Although pipelines are outside the scope of this page, remember:
RepresentationSetupContext.UserSourceTypetells you which pipeline/config should be used.- Your handler is responsible for wiring the visual representation to the correct input/output (e.g. HoloCapturer stream, webcam feed, voice-only, etc.).
You can keep multiple handlers using the same pipeline but different representations, or vice versa.