I have a problem in Unity 2d
NullReferenceException: Object reference not set to an instance of an object RightOne.OnMouseDown () (at Assets/Scripts/RightOne.cs:13) UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
Here's the script:
using UnityEngine;
using System.Collections;
public class RightOne : MonoBehaviour {
private GameObject mainCube;
void Start () {
mainCube = GameObject.Find ("Main Cube");
}
void OnMouseDown () {
if (GetComponent <Renderer> ().material.color == mainCube.GetComponent <Renderer> ().material.color)
mainCube.GetComponent <GameCntrl> ().next = true;
else
mainCube.GetComponent <GameCntrl> ().lose = true;
}
}