Help! Buttons can't find function in scene editor
Hello! I'm trying create a button, that when you press it, something happens. At the moment, it's just supposed to print something in chat, for testing purposes. But for some reason, the button can't find the functions in the scene editor. Here is a screenshot:
If you want my code here it is:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ClickPlot : MonoBehaviour {
void Start () {
}
void Update () {
}
public void kek (){
print ("k");
}
}
This problem seems to just have been happening recently. I could easily add a function to a button before, but it just seems to be appearing now. If you know what's going on, please help!
Answer by stratos_kakalis · Oct 02, 2016 at 03:48 PM
You seem to have done everything properly. I have not run into any issues using buttons recently which version of Unity are you using? If you are trying out the 5.5 beta perhaps its a bug you'll need to report.
I'm currently using version 4.34f1
. I think it might be the version.
Answer by gcardozo · Oct 04, 2016 at 01:45 AM
Your code looks fine. Did you attach your script to the button?
Adding your script to the button: in the inspector of your button, click on "Add Component", then type "ClickPlot" and select your script. Also drag and drop the button from the hierarchy to the "OnClick()" little box in the inspector where it says "None (Object)" (the one with the nipple button).