The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Holograms 210 Chapter 2 example with more than one Hologram
Hello:
I'm working on a apps which basically re-uses the Holograms 210 Chapter 2 example code. So I have a GameObject with the Interactible.cs, InteractibleManager.cs, CursorManager.cs, etc. Idea is to show some UI Text fields attached to the GameObject when user gazes the Hologram and hide them when not. Everything works fine.
Now, the problem arises when I add more GameObjects as the idea is to have more than one Hologram and do the same thing. In this case, I created different classes Interactible1.cs, Interactible2.cs and Interactible3.cs for each GameObject, but continue using only one InteractibleManager.cs. However, things are not working in this case. It seems "GazeEntered" and "GazeExited" messages are not received but InteractibleX.cs code... Looking closer at InteractibleManager.cs, I see it uses "FocusedGameObject.GetComponent< Interactible >( )" which of course the Interactible class doesn't exist (there are 3 classes now). I guess this is the problem....
So how should I modify the code in this case? Should I have 3 InteractibeManagers (one for each Hologram)?
Thank you very much for your support.
Regards;
Gus
Best Answer
-
Optionsjames_ashley ✭✭✭✭
Your logic is probably failing in the InteractibleManager class where you are only checking for the original Interactible type:
if (FocusedGameObject.GetComponent<Interactible>() != null) { FocusedGameObject.SendMessage("GazeEntered"); } ...
A quick fix would be to do additional checks here for Interactible2 and Interactible3. This should get your code to behave the way you want it to.
A better refactor though, would be to use just one behaviour script, Interactible, and add the conditional logic you need there (but I don't know what you are trying to do, so I'm just guessing that this is the way you ultimately want to go.)
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com5
Answers
@gussabina,
Your logic is probably failing in the InteractibleManager class where you are only checking for the original Interactible type:
A quick fix would be to do additional checks here for Interactible2 and Interactible3. This should get your code to behave the way you want it to.
A better refactor though, would be to use just one behaviour script, Interactible, and add the conditional logic you need there (but I don't know what you are trying to do, so I'm just guessing that this is the way you ultimately want to go.)
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com