当前位置:   article > 正文

unity防销毁代码_unity角色不可销毁的脚本

unity角色不可销毁的脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class xiaohui : MonoBehaviour
{
    public object Instance { get; private set; }

    // Start is called before the first frame update
    private void Awake()
    {
        if (Instance != null)
            Destroy(gameObject);
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

脚本挂在过场景不想被销毁的物体上

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号