public class PlayerControl : MonoBehaviour
{
private static PlayerControl instance;
public static PlayerControl Instance
{
get
{
return instance;
}
set
{
instance = value;
}
}
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
}
else
{
Instance = this;
DontDestroyOnLoad(this);
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
【UNITY|C#】DontDestroy+Instance
最新推荐文章于 2024-06-28 16:42:10 发布