Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using Unity.Tutorials.Core;
- public class DontDestroyOnLoad : MonoBehaviour
- {
- public GameObject[] managedObjects;
- private bool isOriginal = false;
- void Awake()
- {
- // Check for existing instances
- if (!foundOriginal)
- {
- isOriginal = true;
- DontDestroyOnLoad(gameObject);
- foreach (GameObject obj in managedObjects)
- {
- if (obj != null)
- {
- // Remove SceneObjectGuid components
- SceneObjectGuid[] guids = obj.GetComponentsInChildren<SceneObjectGuid>(true);
- foreach (SceneObjectGuid guid in guids)
- {
- DestroyImmediate(guid);
- }
- DontDestroyOnLoad(obj);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement