Function in Awake() does not execute on mobile android device?
I've written a code that generates a lines of string from a .Json file onto a panel with a button component when the panel is clicked. Once the scene is loaded the text is supposed to be displayed onto the panel automatically, so i used :
public void Awake()
{
nextQuestion = true;
OnClick();
}
public void OnClick(){
QuestionBegin();
int randomIndex = Random.Range(0, questionsData["quiz"].Count);
GameObject.Find("Screen/QuestionPanel/Quest").GetComponentInChildren<Text>().text = questionsData["quiz"][randomIndex]["question"].ToString();
GameObject.Find("Category/Text").GetComponentInChildren<Text>().text = questionsData["quiz"][randomIndex]["category"].ToString();
GameObject.Find("QuestNum").GetComponentInChildren<Text>().text = "Questions " + numberQuestions.ToString()+"/120";
nextQuestion = false;
clickAnswer = true;
}
}
<LengthyFunction>(){
.....
.....
.....
nextQuestion = true;
clickAnswer = false;
}
}
}
It works smoothly on the game and unity remote, but when I build the apk and run it in android the OnClick() function does not start and this is a problem. Is there something in the unity settings that I missed or does onclick not work on mobile or is it something completely different?
screenshot-7.png
(35.5 kB)
Comment
Your answer
Follow this Question
Related Questions
Button OnClick function? 1 Answer
OnClick Functions Not Appearing,OnClick Not Showing Public Functions 1 Answer
Android GUI Button crash 1 Answer