16 lines
396 B
C#
16 lines
396 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DontDestroyController : MonoBehaviour {
|
|
[SerializeField] public string myTag;
|
|
void Awake() {
|
|
GameObject[] objs = GameObject.FindGameObjectsWithTag(myTag);
|
|
|
|
if (objs.Length > 1) {
|
|
Destroy(this.gameObject);
|
|
}
|
|
|
|
DontDestroyOnLoad(this.gameObject);
|
|
}
|
|
} |