Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Globals : MonoBehaviour
- {
- public static Globals instance;
- public string roomID;
- public List<Room> rooms;
- private void Awake()
- {
- if (instance == null)
- {
- instance = this;
- }
- else if (instance != this)
- {
- Destroy(gameObject);
- }
- DontDestroyOnLoad2(gameObject);
- }
- private void DontDestroyOnLoad2(GameObject myObj)
- {
- Transform parentTransform = myObj.transform;
- while (parentTransform.parent != null)
- {
- parentTransform = parentTransform.parent;
- }
- GameObject.DontDestroyOnLoad(parentTransform.gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment