美文网首页
单例-unity

单例-unity

作者: _Pman | 来源:发表于2020-06-30 17:11 被阅读0次
        public static GameManager instance;
    
        private void Awake()
        {
            instance = this;
        }
    

    或者定义属性Instance访问

        private static GameManager instance;
    
        public static GameManager Instance { get => instance; set => instance = value; }
    
        private void Awake()
        {
            Instance = this;
        }
    

    相关文章

      网友评论

          本文标题:单例-unity

          本文链接:https://www.haomeiwen.com/subject/ojwxqktx.html