Object reference Problems

So i am trying to code a simple code that checks if i am clicking the left mouse ( just for practice since i am new ). I keep on getting Object reference not set to an instance of an object… i am new programmer especially to c# and i think i am sure i set e to an instance of an object event? Please help me out

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
		Event e = new Event(); // This is e being declared an object of event
	       e = Event.current;
	    if (e.button == 0 && e.isMouse)
		    print ("Left Mouse");


Why are you using events, when you can use Input?

Just replace all your event code with:


It’s that simple :wink:

Hope this helps,