/// <summary> /// 禁用脚本的时候触发 /// </summary> void OnDisable() { if (mCurrentLoom == this) { mCurrentLoom = null; } }
static void Initialize() { if (false == initialized) { initialized = true; // monobehavior单例模式的写法 var loomgameobject = new GameObject("Loom"); mCurrentLoom = loomgameobject.AddComponent <UtilTreadLoom>(); } }
void Awake() { mCurrentLoom = this; initialized = true; }