**I am trying to attach this script to my button “onclick” function , so that when i click it and if its color is same as displaycolor “hello” is displayed . But i am getting error message saying- “Object reference not set to an instance of an object” . SO please kindly help. **
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class OnClick : MonoBehaviour {
public void SayHello(string hello
) {
if (GetComponent<Image>().color == GameObject.FindGameObjectWithTag("DisplayButton").GetComponent<Image>().color)
{
Debug.Log("Hello");
}
}
}