wacki / Unity-VRInputModule

MIT License
89 stars 33 forks source link

Activate/Deactivate laser pointer when gameobject.setactive(true/false) #9

Open SpaceHuskyZero opened 7 years ago

SpaceHuskyZero commented 7 years ago

Love this pointer but I'm looking for a way to deactivate it when the GUI is disabled. I've tried to do it myself but can't seem to get it to work. I've tried deactivating the scripts, the pointer objects, etc but nothing works. I am VERY new to Unity and coding so it's no surprise that I can't figure it out on my own. Would love for you guys to help solve this!

Just attempted the following under protected virtual void in IUILaserPointer: if(GUICanvas == true) { laserPointer.enabled = true; } else if(GUICanvas == false) { laserPointer.enabled = false; }

Just got a NullReferenceException error. No idea how to fix that.

paulhayes commented 7 years ago

Hi there. I'll patch this soon in my fork. Will let you know when it's in and tested.

BudsHub commented 7 years ago

Yeah, I am pretty expperienced but cant get the pointer to turn off. I can turn the menu itself on and off by calling a method from the button to disable the menu gameObject. If I call a method from the button to disable the viveLaserPointer.cs the script disables ok but the pointer is still rendered. In my method I call : viveUILaserPointer.GetComponent().enabled = false; I also tried to disable the IUILaserPointer.cs again using the same syntax as above but still no joy. The pointer will stay at a fixed distance once the ViveUILaserPointer.cs is disabled. I can easily switch scenes using seperate scenes, however i need the menu to be visible in the game scene. Any help greatly appreciated.