Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- // Object.DontDestroyOnLoad example.
- //
- // This script example manages the playing audio. The GameObject with the
- // "music" tag is the BackgroundMusic GameObject. The AudioSource has the
- // audio attached to the AudioClip.
- public class DontDestroy : MonoBehaviour
- {
- private static GameObject _instance;
- void Awake()
- {
- //if we don't have an [_instance] set yet
- if (!_instance)
- {
- _instance = gameObject;
- DontDestroyOnLoad(gameObject);
- }
- //otherwise, if we do, kill this thing
- else {
- Destroy(gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement