Experiments with Shared Holograms and Azure Blob Storage/UDP Multicasting (Part 3)

NB: The usual blog disclaimer for this site applies to posts around HoloLens. I am not on the HoloLens team. I have no details on HoloLens other than what is on the public web and so what I post here is just from my own experience experimenting with pieces that are publicly available and you should always check out the official developer site for the product documentation.

Following up on my previous post, one of the “to do” items was to avoid the hard-coding of the mechanism via which ‘shared’ holograms were to be created.

In the example code below (taken from the TestScript in the Unity project) which makes a call to SharedCreator.Create…

        SharedHologramsController.Instance.Creator.Create(
            "Cube",
            position,
            forward,
            new Vector3(0.1f, 0.1f, 0.1f),
            cube =>
            {
                ChangeMaterial(cube, this.GreenMaterial);
                cube.AddComponent<BoxCollider>();
            }
        );

the Create method expects to be passed the name of a Unity primitive like “Cube” or “Sphere”. I updated the repo so as to add a simple interface via which this can hopefully be abstracted;

using System;
using UnityEngine;

public interface ICreateGameObjects
{
    void CreateGameObject(string gameObjectSpecifier, Action<GameObject> callback);
}

and then exposed a property on the SharedCreator via which an implementation can be plugged in. By default, that property value will be an instance of a class named PrimitiveGameObjectCreator which simply encapsulates logic which was previously hard-wired into the SharedCreator class.

While doing this, I was very conscious that I really need to just bite the bullet and plug in an IoC container which would probably make the whole thing a lot nicer. Pete has some notes on that in his post here.

2 thoughts on “Experiments with Shared Holograms and Azure Blob Storage/UDP Multicasting (Part 3)

  1. Pingback: Experiments with Shared Holograms and Azure Blob Storage/UDP Multicasting (Part 4) – Mike Taulty

  2. Pingback: Experiments with Shared Holograms and Azure Blob Storage/UDP Multicasting (Part 6) – Mike Taulty

Comments are closed.