How to add script to onvaluechanged of toggle of a prefab on runtime?
Somehow ... I can't add the function of the script and its value to onvaluechanged of toggle on runtime. Unity version is 2018.2.0f2
*The comment out part of the script also does not work.
Is there anyone who can help with this ??
20181207.jpg
(345.8 kB)
Comment
The monobehavior class need to have funciton like this
public void ClickToggle(bool toggle)
{
// If else function here
}
When adding a callback to events using a script, they do not appear in the inspector but they are called anyway.
Answer by ElaxomoeR · Dec 10, 2018 at 07:50 AM
I found a workaround and it is perfectly work!! Thank you Google!
public class BoardSelectSpecialScript : MonoBehaviour, IPointerDownHandler
{
public int _id;
public void OnPointerDown(PointerEventData eventData)
{
BoardSelect();
}
//This function is same as mM.OnSelectBoard(id);
public void BoardSelect()
{
PlayerPrefs.SetInt("BOARD_ID", _id);
PlayerPrefs.Save();
}
}
Your answer
Follow this Question
Related Questions
Change skin on runtime 1 Answer
choose texture option when lookat 0 Answers
Runtime Normal Map Import Issues 1 Answer
Why does Nav Mesh Run Slower in build mode than in Editor? 1 Answer