// Use this for initialization void Start() { //Gets our MusicPlayerScript (remember, get the object first, then the component on that object GameObject musicPlayerObject = GameObject.Find("MusicPlayer"); musicPlayer = musicPlayerObject.GetComponent <MusicPlayerScript> (); }
// Use this for initialization void Start() { if (musicPlayer != null) { musicScript = musicPlayer.GetComponent <MusicPlayerScript>(); } }
// Use this for initialization void Start() { if (musicPlayer != null) { musicScript = musicPlayer.GetComponent <MusicPlayerScript>(); } if (mainCamera != null) { cameraControl = mainCamera.GetComponent <CameraFollow2D> (); } if (Boss != null) { bossControl = Boss.GetComponent <BossScript> (); bossEnter = Boss.GetComponent <MoveScript> (); bossCollider = Boss.GetComponent <PolygonCollider2D> (); bossControl.enabled = false; bossEnter.enabled = false; bossCollider.enabled = false; } if (GUI != null) { guiScript = GUI.GetComponent <GUIScript> (); } entranceCountdown = -11; }
// Start is called before the first frame update void Start() { audio = gameObject.AddComponent <AudioSource>(); cs = GameObject.Find("Main Camera").GetComponent <CameraShader>(); mps = GameObject.Find("Main Camera/MusicPlayer").GetComponent <MusicPlayerScript>(); movscript = GameObject.Find("Player").GetComponent <PlayerMovement>(); Debug.Log("Battlemaster initialized"); }
// Use this for initialization void Awake () { if (instance != null) { Destroy(gameObject); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
void Awake() { if (!player) { player = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
void Start() { btn = this.GetComponent <Button>(); //gets music button btn.onClick.AddListener(SwitchMusic); //gets the script that controls music from main camera musicManager = GameObject.Find("MusicPlayer").GetComponent <MusicPlayerScript>(); if (!musicManager.musicOn) { ChangeImage(); } }
// Use this for initialization void Start() { if (instance != null) { Destroy(gameObject); } else //instance is still null so this is the first music player { instance = this; DontDestroyOnLoad(gameObject); } }
void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
void Awake() { if(instance != null && instance != this) { Destroy(this.gameObject); } else { instance = this; } DontDestroyOnLoad (this.gameObject); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Awake() { if (instance != null) { print("Duplicate Music Player is self-destructing!"); Destroy(gameObject); } else // Instance is still null so this is the first Music Player { instance = this; DontDestroyOnLoad(gameObject); } }
// Use this for initialization void Start() { music = this.GetComponent <AudioSource>(); if (musicInstance == null) // first time music is initialized { IsMusicOn = true; musicInstance = this; music.clip = startAndOptions; music.loop = true; music.Play(); } DontDestroyOnLoad(gameObject); }
// Use this for initialization void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); print("Duplicate Music Player is self detructing!"); } }
void Awake() { Debug.Log("Music Player Awake: " + GetInstanceID()); if (instance != null) //checks if an instance of this exists { Destroy(gameObject); //destroy's itself if an instance already exists Debug.Log("Music Player Copy Destroyed: " + GetInstanceID()); } else { instance = this; //if instance is set to nothing, there is no instance. So set instance to this object. GameObject.DontDestroyOnLoad(gameObject); //don't destroy this object. } }
//static bool availablePlayer = false; // Use this for initialization void Start() { //if (availablePlayer == false) if (duplicateInstance == null) { DontDestroyOnLoad(gameObject); duplicateInstance = this; //availblePlayer = true; } else { Destroy(gameObject); print("Duplicate Music Player is self destructing!"); } }
void Awake() { Debug.Log("Music Player Awake" + GetInstanceID()); if (instance != null) { Destroy(gameObject); print("duplicate music player destoyed"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
// Use this for initialization void Start() { print("Player Start"); if (instance != null) { print("Duplicate Music Player is self-Destructing"); Destroy(gameObject); } else //INSTANCE IS STILL NULL { instance = this; DontDestroyOnLoad(gameObject); } DontDestroyOnLoad(gameObject); }
// Use this for initialization private void Awake() //Awake is always executed first { print("player awake"); if (instance != null) { print("Music player destroyed"); Destroy(gameObject); //Therefore there will be no dublicate //music playing in the background } else //instance is null so it is the first //music player { instance = this; DontDestroyOnLoad(gameObject); } }
void Start() { //Debug.Log ("Music Player Awake" + GetInstanceID()); if (instance != null && instance != this) { Destroy(gameObject); print("duplicate music player destoyed"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); music = GetComponent <AudioSource>(); music.clip = startClip; music.loop = true; music.Play(); } }
//Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
// Use this for initialization void Start() { IsMusicOn = true; if (MainMusic == null) { MainMusic = this; gameObject.audio.Play(); GameObject.DontDestroyOnLoad(gameObject); } // gameObject is a pre-defined property // note that the game object is an instance of the game object the script is attaeched to // in this case it's the MusicPlayer game object /* * public GameObject gameObject * { * get * { * return this.InternalGetGameObject (); * } * } */ }
// Use this for initialization void Start() { musicPlayer = music.GetComponent <MusicPlayerScript> (); UI = UIContainer.GetComponent <PauseMenuScript>(); }