Hi everyone, i had an error:
“NullReferenceException: Object reference not set to an instance of an object”
I was trying to put an image to a button, like this:
public Texture[] buttonTxt = new Texture[10];
void OnGUI() {
if(createButtonT(50, 50, 100, 30, buttonTxt[0], style)) {
}
}
he throws a exception as you can see, but i’ve looking for the answer for my question and i didn’t found a case like the mine. My cretaButtonT() is a method that creates a button with a texture, seated on other script:
public bool createButtonT(float left, float top, float width, float height, Texture content, GUIStyle style) {
return GUI.Button(new Rect((screenX-screenX)+left, (screenY-screenY)+top, width, height), content, style);
}
Thanks for who will help me =)