- Home /
Question by
KnightRiderGuy · Dec 03, 2015 at 02:00 PM ·
c#animatorscene-switchingdontdestroyonload
Why do I loose my Animator?
When I return to may main scene the animation is missing, when I go back to the Scene where the animation originated it is also missing. The Script has the Don't destroy code on it.
public class UIManagerScript : MonoBehaviour {
public Animator LEDlights;
public static UIManagerScript uiManagerScr;
void Awake () {
if (uiManagerScr == null) {
DontDestroyOnLoad (gameObject);
uiManagerScr = this;
} else if (uiManagerScr != this) {
Destroy (gameObject);
}
}
public void PlayLEDLightsAnimation()
{
GetComponent<Animator> ();
LEDlights.SetBool ("notPlaying", !LEDlights.GetBool ("notPlaying"));
}
public void GoSurveillanceModeToggle(){
//Send to Sending script for message out to Arduino
Sending.sendBlue ();
}
public void TogglePlay()
{
if (GetComponent<AudioSource> ().isPlaying)
{
GetComponent<AudioSource>().Stop();
}
else
{
GetComponent<AudioSource>().Play();
}
}
//Quit Button
public void GoQuit(){
StartCoroutine(LoadQuit("ThreeD_Overview"));
}
IEnumerator LoadQuit(string levelMain){
yield return new WaitForSeconds(0.5f); // wait time
Application.LoadLevel(levelMain);
}
}
screen-shot-2015-12-03-at-74746-am.jpg
(217.9 kB)
screen-shot-2015-12-03-at-74813-am.jpg
(190.8 kB)
Comment