using System.Collections; using System.Collections.Generic; using UnityEngine; namespace MyFrameworkPure { /// /// 保证场景中物体唯一 /// public class OnlyOne : MonoBehaviour { private static OnlyOne instance; void Awake() { if (instance == null) instance = this; else if (instance != this) DestroyImmediate(gameObject); } } }