Hi Aren,
I have a set of UICheckboxes being used to choose the music in game - everything works fine until I try setting the saved choice in awake/start. Because the behaviour of the UICheckbox is to Activate/Deactivate during initialisation.
My code saves the currently playing tune into PlayerPrefs and reads this back in Awake. I then want to set the corresponding UICheckbox to be active, however as the script itself activates/deactivates them the choice of the user gets immediately overwritten, I have seen another post from another using suggesting a 'doNotFireEventsOnStart' override and feel that this would be a very good addition to NGUI in general?
This is an extract of the code being called in Awake on the MusicController:
public List<MusicChooser> MusicFiles;
public AudioSource MusicPlayer;
void Awake ()
{
int MySong;
if (!PlayerPrefs.HasKey ("MusicPlaying")) {
MySong = 0;
} else {
MySong = PlayerPrefs.GetInt ("MusicPlaying");
}
Debug.Log ("I was playing: " + MySong);
MusicPlayer.clip = MusicFiles [MySong].MusicSelection;
MusicPlayer.Play ();
MusicFiles[MySong].GetComponent<UICheckbox>().startsChecked = true;
}
I have tried altering the script execution order but this doesn't seem to have any effect whatsoever.
Any ideas how I can fix this from happening?
Regards,
M