So I've got a laser pointer that works with the GUI nicely, the only problem is, it's ALWAYS active. The pointer can be downloaded from GitHub. I'm very new to coding but I've tried everything I can think of and find on the web to solve my problem. I believe I know what parts I need to deactivate however I keep getting a NullReferenceException error which is preventing me from seeing if it works. Here's my code.
public class DeactivatePointer : MonoBehaviour {
public GameObject GUICanvas;
public GameObject controller;
private Wacki.ViveUILaserPointer vivePointer;
private Wacki.IUILaserPointer laserPointer;
void Start()
{
vivePointer = controller.GetComponent<Wacki.ViveUILaserPointer>();
vivePointer.enabled = false;
}
void Update()
{
if(GUICanvas == false)
{
vivePointer.enabled = false;
}
else if(GUICanvas == true)
{
vivePointer.enabled = true;
}
}
}
Any ideas?