Skip to content

Instantly share code, notes, and snippets.

@joshalanwagner
Created August 18, 2015 01:10
Show Gist options
  • Select an option

  • Save joshalanwagner/4486c6f3370ee1a62369 to your computer and use it in GitHub Desktop.

Select an option

Save joshalanwagner/4486c6f3370ee1a62369 to your computer and use it in GitHub Desktop.
Alternate code for Music Player script.
using UnityEngine;
using System.Collections;
public class MusicPlayer : MonoBehaviour {
static bool initialRun = true;
void Start ()
{
if (initialRun == true) {
GameObject.DontDestroyOnLoad (gameObject);
initialRun = false; // It will be false the next time this script is run
} else {
Destroy (gameObject);
print ("Destroy duplicate");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment