0

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?

Community
  • 1
  • 1
Stewie
  • 105
  • 2
  • 1
    Read the answers in the duplicate, it will teach you how to debug your program and how to identify what is null. Once you know the specific thing that is null and you don't understand why it is null edit this question or open a new one asking why specifically a variable is null when you expect it not to be. – Scott Chamberlain Mar 15 '17 at 16:11
  • I've tried reading these articles before but I just can't seem to grasp it. I'll look back into it and see what I can find. – Stewie Mar 15 '17 at 16:34
  • No need to read articles, just read the topvoted answer on the linked duplciate – Scott Chamberlain Mar 15 '17 at 16:52
  • However here is a article you should read it will help you out a lot over your programming lifetime https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – Scott Chamberlain Mar 15 '17 at 16:53

0 Answers0