microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

GazeManager.FocusedObject as static variable #110

Closed yosun closed 8 years ago

yosun commented 8 years ago

is there a case where GazeManager.FocusedObject might vary - i.e., would there be multiple gaze cursors in a single scene?

namely, why isn't FocusedObject a static variable - when would it need to be accessed as an instance (and multiple instances)?

jwittner commented 8 years ago

GazeManager follows the Singleton paradigm rather than the static class one. For this reason the Focused object is relative to the GazeManager object. To note, for better or worse the HoloToolkit-Unity Singleton class chooses the first available Instance, but doesn't prevent multiple instances from existing. There are many arguments for the current implementation, a key one is to allow the GazeManager to vary across scenes. After placing an instance of the GazeManager into the scene, from script you can do GazeManager.Instance.ForcusedObject and get very similar behavior.