- Home /
UI button dosent show function
hi guys, i created a canvas and in it there is a panel with some buttons on it.
on the canvas itself there is script called MenuMeneger and to each panel there is a object called menu
using UnityEngine;
using System.Collections;
public class MenuManager : MonoBehaviour {
public Menu currentMenu;
public GameObject PlayerSettings ;
void Start(){
showMenu (currentMenu);
}
public void showMenu(Menu menu){
currentMenu.setIsOpen (false);
currentMenu = menu;
currentMenu.setIsOpen (true);
}
public void chooseGameType(Menu menu,gametype myGameType){
PlayerSettings.GetComponent<PreLevelSettings> ().setGameType (myGameType);
currentMenu.setIsOpen (false);
currentMenu = menu;
currentMenu.setIsOpen (true);
}
public void choosePlayerRole(Menu menu,playerRole myPlayerRole){
PlayerSettings.GetComponent<PreLevelSettings> ().setplayerRole (myPlayerRole);
currentMenu.setIsOpen (false);
currentMenu = menu;
currentMenu.setIsOpen (true);
}
public void exitMenu(){
Application.Quit ();
}
}
somehow functions chooseGameType choosePlayerRole dosent show on the button select and function showMenu and exitMenu does
thanks in advance
Gal
Answer by hangemhigh · Apr 19, 2015 at 06:33 PM
Its not showing because the function "choosePlayerRole" takes 2 parameters which are Menu menu,playerRole myPlayerRole. For it to show up, the function must take only 1 parameter. These parameters could be GameObject,int,float,string.
You can't do it with click stuff on the Editor. That's the limit they put on it but you can ins$$anonymous$$d detect the button click all from code and avoid using the Unity click stuff to add function from the editor. Let me know if you need an example. If you do, post the function you want to call when the button is clicked and I will help you out.
Your answer
Follow this Question
Related Questions
Unity UI 4.6 Canvas Enable/Disable make Accessible 2 Answers
UI Button and character actions 1 Answer
Cannot click UI button. 4 Answers
Hidden Canvas, doesn't disable interaction with buttons. 1 Answer