Input System
One of the first things necessary for this project was an Input System that would work with both the HoloLens and in the Unity Editor. This would allow us to debug the project inside Unity before exporting it to the HoloLens for further testing, helping streamline development.
The Input System allows users to mouse over objects (or look at them through the HoloLens) which sets their layer to Focused. On a HoloLens tap or mouseclick, the object will follow the users gaze or mouse pointer respectively. When the user taps again or lets go of the mouse, the object will stop moving and it's layer will be reset.
Early Input System demonstrating dragging of ABCs
A diagram showing what happens when the user presses the left mouse button. The logic is very similar to HoloLens input. The whole input system is not shown. Orange represents conditionals, blue represents statements.
Full resolution here
Component System
Detatching Ethernet and CommsDB9 wires from the ABC, then detaching the ABC
After objects were able to be moved, the next step was to have objects attaching to eachother. When a user would start dragging an object, it would be de-parented from any objects it was part of. When the user let go of an object, a raycast would be performed which would ignore the Focused Object layer, allowing this system to detect objects behind where the user is dragging.
Each object in the component system inherits from a base InteractableObj, which provides a number of variables to help categorise components by functionality and also which objects they can attach to.
When a user stops dragging an object and the raycast is performed, if the two objects are compatible, one will be parented to another and attach to the correct position.
The component system allows the game to handle large numbers of different objects with differing functionality, this includes buttons, cables, ABCs, and even the switches for the binary puzzle.
Through the Component System, it's relatively easy to introduce new objects into the game. In simple terms, each object needs it's own script which sets up its ActivationType (an enum) and what it attaches to. A Draggable object will be able to be moved and attached to different objects. A Switch object will be able to be toggled. Creating additional ActivationTypes is also relatively easy in the current system.
Objects go to the correct attach location by finding a GameObject on the ToAttachTo object called "AttachPos", snapping to this objects location.
In the example on the right, ABCWire inherits from InteractableObj, is a Draggable object, and attaches to the ABC.
Streamlining
Later on during the development of our project, the Input System went through a much-needed simplification, which was necessary as the dragging and dropping was very pernickety and would cause problems when we had a large number of components in the scene.
This removed the capability to drag and drop and favored the use of buttons instead, where each button has the ability to be tied to a function. By only having to press buttons to interact with objects, the gameplay and user experience was streamlined and improved, not to mention reducing the complexity of our most complex system.
A later version of the input system demonstrating the ease of use
Diagram demonstrating the Component Systems inheritance and attachment