protected virtual void OnDestroy() { if (destroyHandler != null) { destroyHandler.Invoke(ctrlScript); } if (apiReleaseHandler != null) { apiReleaseHandler.Invoke(apiScript); } apiScript = null; ctrlScript = null; awakeHandler = null; startHandler = null; enableHandler = null; disableHandler = null; destroyHandler = null; apiReleaseHandler = null; }
protected virtual void Awake() { string apiScriptName = moduleName + "API"; apiScript = LuaManager.Get().CreateLuaObject(apiScriptName); ctrlScript = LuaManager.Get().CreateLuaObject(moduleName); //api抓取 XLuaBehavior_APIInit apiInitHandler = apiScript.GetInPath <XLuaBehavior_APIInit>(apiScriptName + ".Init"); apiReleaseHandler = apiScript.GetInPath <XLuaBehavior_APIRelease>(apiScriptName + ".Release"); //ctrl抓取 awakeHandler = ctrlScript.GetInPath <XLuaBehavior_Awake>(moduleName + ".Awake"); startHandler = ctrlScript.GetInPath <XLuaBehavior_Start>(moduleName + ".Start"); enableHandler = ctrlScript.GetInPath <XLuaBehavior_OnEnable>(moduleName + ".OnEnable"); disableHandler = ctrlScript.GetInPath <XLuaBehavior_OnDisable>(moduleName + ".OnDisable"); destroyHandler = ctrlScript.GetInPath <XLuaBehavior_OnDestory>(moduleName + ".OnDestory"); apiInitHandler.Invoke(apiScript, transform); awakeHandler.Invoke(ctrlScript, apiScript); }