hello I have a button plus a box which alpha is 0 from the start, the button works but the box doesn't appear. In the code the I did use 'getcontents' but it seems it didn't work, the button executes a debug.log so that's how I know that is working, the errors I get before the button click is; before button click
and the errors after button click (including the debug.log) after button click
it says i haven't attached my 'Menuee' although i have (yes i know i spelt it like that) show here;
and i have attached my Ibutton (the button)
my code is below;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class startbutton : MonoBehaviour {
public Button Ibutton;
public CanvasGroup Menuee;
public void Start () {
Ibutton.onClick.AddListener(TaskOnClick);
}
public void TaskOnClick(){
Debug.Log ("yes");
Menuee.interactable= true;
Menuee.alpha = 1;
}
}
CodePudding user response:
In the screen shot you don't seem to have anything assigned to Button Ibutton
.
Another reason for such errors could be that you might have assigned the startbutton
script to another game object somewhere and that instance of the script doesn't have the properties assigned.
CodePudding user response:
You didn't add a button on your public Button Ibutton;
You might also some how delete EventManager that comes with canvas you created on hierarch window.