项目开发过程中经常使用到,脚本是继承monobehavior,使用起单例来比较简单。
using UnityEngine; using System.Collections; public class test: MonoBehaviour { public static test instance; private void Awake() { if (ins != null) { Destroy(this.gameObject); } else { ins = this; } } void Update () { } }
此博客出自TaoHu,转载请注明原文地址 |
博客地址:http://www.cnblogs.com/htwzl/ |
-- Unity3D 学习交流 --