void OnDisable() { if (luaObject != null && L != null) { LuaController.RemoveEventListener(luaObject); } }
public void Dispose() { if (scriptIsReady) { if (true || !is_OnDisable) { is_OnDisable = true; LuaController.RemoveEventListener(luaObject); } } started = false; scriptIsReady = false; if (l_OnDestroy != null && L != null) { l_OnDestroy(luaObject); } l_Start = null; l_OnDestroy = null; l_Update = null; l_onEvent = null; l_OnDisable = null; l_OnEnable = null; l_OnApplicationPause = null; if (L != null && luaObject != null) { luaObject.Dispose(); } luaObject = null; }
void OnEnable() { if (luaObject != null) { LuaController.RegisterEventListener(luaObject); } }
public void OnPointerClick(PointerEventData eventData) { if (showDetail) { LuaController.DispatchEvent("OnClickItemIcon", null, HeroInfo); } }
void luaStart() { if (!started || luaObject == null) { return; } needCallLuaStart = false; if (l_Start != null) { LuaFunction func = luaObject.Get <LuaFunction>("Start"); if (args != null) { //l_Start(luaObject, args); LuaController.Sync(func, luaObject, args); } else { LuaController.Sync(func, luaObject); // l_Start(luaObject); } func = null; } else { LuaRegisterEventAndCallAfterStart(); } }
void LuaNPCScript(GameObject obj) { if (Time.time - time > interDeltime) { time = Time.time; MapPlayer mapPlayer = GetComponent <MapPlayer>(); MapMonster mapMonster = GetComponent <MapMonster>(); if (mapPlayer != null && mapPlayer.enabled) { mapPlayer.UpdateDirection((obj.transform.position - transform.position).normalized, true); } else if (mapMonster != null && mapMonster.enabled) { mapMonster.UpdateDirection((obj.transform.position - transform.position).normalized); } string fileName = (script == null) ? "guide/" + LuaTextName + ".lua" : script.name; if (luaThreadEval == null) { luaThreadEval = LuaController.GetLuaValue <LuaThreadEval>("ThreadEvalWithGameObject"); } if (luaThreadEval != null) { luaThreadEval(fileName, fileName, this, values); } else { LuaController.DoFile(fileName, values); } } }
public void OnPointerClick(PointerEventData eventData) { if (showDetail) { int[] msg = { pos, 1 }; LuaController.DispatchEvent("OnClickItemIcon", EquipInfo, msg); } }
public void OnInteractableClick(GameObject interactable, System.Action callback) { if (self_player != null) { Vector3 pos = self_player.Interact(interactable, callback); LuaController.DispatchEvent("NAV_PLAYER_MOVE", pos.x, pos.y, pos.z); } }
void OnDestroy() { Dispose(false); if (instance == this) { instance = null; } }
public void OnGroundClick(BaseEventData data) { if (self_player != null) { PointerEventData pData = (PointerEventData)data; Vector3 pos = pData.pointerCurrentRaycast.worldPosition; pos = self_player.MoveTo(pos); LuaController.DispatchEvent("NAV_PLAYER_MOVE", pos.x, pos.y, pos.z); } }
void OnDestroy() { if (instance == this) { instance = null; } Dispose(false); //Statistics.SendData(); }
public void LuaRegisterEventAndCallAfterStart() { is_OnDisable = false; LuaController.RegisterEventListener(luaObject); scriptIsReady = true; foreach (CallInfo info in _callAfterStart) { Call(info.eventName, info.param); } _callAfterStart.Clear(); }
void Start() { if (script != null) { LuaController.DoStringInThread(script.text, script.name, gameObject); } if (!string.IsNullOrEmpty(scriptFileName)) { LuaController.DoStringInThread(FileUtils.LoadBytesFromFile(scriptFileName), scriptFileName, gameObject); } }
void OnDisable() { if (scriptIsReady && luaObject != null && L != null && !is_OnDisable) { if (l_OnDisable != null) { l_OnDisable(luaObject); } is_OnDisable = true; LuaController.RemoveEventListener(luaObject); } }
void OnEnable() { if (scriptIsReady && luaObject != null) { if (l_OnEnable != null) { l_OnEnable(luaObject); } is_OnDisable = false; LuaController.RegisterEventListener(luaObject); } }
public static IEnumerator UnloadThread() { Debug.LogFormat("ResourcesManager.UnloadUnusedAssets"); var op = AssetManager.UnloadAll(false); while (op != null && !op.isDone) { yield return(null); } LuaController.Collect(); System.GC.Collect(); Debug.LogFormat("ResourcesManager.UnloadUnusedAssets completed"); }
void luaAwake() { if (l_Awake != null) { if (args != null) { l_Awake(luaObject, args); } else { l_Awake(luaObject); } } LuaController.RegisterEventListener(luaObject); }
public static IEnumerator LoadPersistentScene() { if (!loading) { loading = true; if (LuaController.GetLuaState() == null) { yield return(SceneManager.LoadSceneAsync(PRESISTENT_SCENE_BUILD_INDEX, LoadSceneMode.Single)); } } while (LuaController.GetLuaState() == null) { yield return(null); } }
public virtual void Interact(GameObject obj) { if (Time.realtimeSinceStartup - last_interact_time < interact_protect_time) { return; } last_interact_time = Time.realtimeSinceStartup; if (script != null) { if (Character) { values [0] = Character.gameObject.transform.localPosition.x.ToString(); values [1] = Character.gameObject.transform.localPosition.y.ToString(); values [2] = Character.gameObject.transform.localPosition.z.ToString(); } values [3] = Playerid; LuaController.DoString(script.bytes, values); } }
public void OnPointerClick(PointerEventData eventData) { if (showDetail) { int[] msg = { pos, Count }; if (onClick != null) { onClick(); } else { LuaController.DispatchEvent("OnClickItemIcon", ItemInfo, msg); } if (_onClick != null) { _onClick.Invoke(); } } }
void Awake() { var p = Application.backgroundLoadingPriority; Application.backgroundLoadingPriority = ThreadPriority.High; if (instance != null) { DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(this.gameObject); L = new LuaEnv(); L.AddLoader(FileUtils.Load); LuaBehaviour.CleanStatlessFile(); L.Global.Set <string, XLua.LuaDLL.lua_CSFunction>("WARNING_LOG", CustomSettings.PrintWarning); L.Global.Set <string, XLua.LuaDLL.lua_CSFunction>("ERROR_LOG", CustomSettings.PrintError); L.Global.Set <string, XLua.LuaDLL.lua_CSFunction>("BATTLE_LOG", CustomSettings.BATTLE_LOG); L.Global.Set <string, XLua.LuaDLL.lua_CSFunction> ("loadstring", CustomSettings.LoadString); IService[] services = gameObject.GetComponents <IService>(); for (int i = 0; i < services.Length; i++) { services[i].Register(L); } //L.DoString("require('LuaDebug')('localhost',7003)"); L.DoString("require 'utils.init'"); _RegisterEventListener = L.Global.Get <System.Action <object> >("RegisterEventListener"); _RemoveEventListener = L.Global.Get <System.Action <object> >("RemoveEventListener"); _DispatchEvent = L.Global.Get <DispatchEventDelegate>("DispatchEvent"); _StartLuaCoroutineDelegate = L.Global.Get <StartLuaCoroutineDelegate>("StartCoroutine"); _Sync = L.Global.Get <SyncDelegate>("Sync"); }
public virtual void Interact(GameObject obj) { if (Time.realtimeSinceStartup - last_interact_time < interact_protect_time) { return; } last_interact_time = Time.realtimeSinceStartup; MapPlayer mapPlayer = GetComponent <MapPlayer>(); MapMonster mapMonster = GetComponent <MapMonster>(); if (mapPlayer != null && mapPlayer.enabled) { mapPlayer.UpdateDirection((obj.transform.position - transform.position).normalized, true); } else if (mapMonster != null && mapMonster.enabled) { mapMonster.UpdateDirection((obj.transform.position - transform.position).normalized); } else { } string fileName = (script == null) ? "guide/" + LuaTextName + ".lua" : script.name; if (luaThreadEval == null) { luaThreadEval = LuaController.GetLuaValue <LuaThreadEval>("ThreadEvalWithGameObject"); } if (luaThreadEval != null) { luaThreadEval(fileName, fileName, this, values); } else { LuaController.DoFile(fileName, values); } }
void Awake() { if (instance != null) { DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(this.gameObject); L = new LuaEnv(); L.AddLoader(FileUtils.Load); //L.Global.Set<string, XLua.LuaDLL.lua_CSFunction>("WARNING_LOG", CustomSettings.PrintWarning); //L.Global.Set<string, XLua.LuaDLL.lua_CSFunction>("ERROR_LOG", CustomSettings.PrintError); //L.Global.Set<string, XLua.LuaDLL.lua_CSFunction>("loadstring", CustomSettings.LoadString); IService[] services = gameObject.GetComponents <IService>(); for (int i = 0; i < services.Length; i++) { services[i].Register(L); } L.DoString("require 'main'"); MainAction = L.Global.Get <System.Action>("main"); if (MainAction != null) { MainAction(); } //_RegisterEventListener = L.Global.Get<System.Action<object>>("RegisterEventListener"); //_RemoveEventListener = L.Global.Get<System.Action<object>>("RemoveEventListener"); //_DispatchEvent = L.Global.Get<DispatchEventDelegate>("DispatchEvent"); //_StartLuaCoroutineDelegate = L.Global.Get<StartLuaCoroutineDelegate>("StartCoroutine"); }
public void OnClick(GameObject obj) { LuaController.DoString(script.bytes, gameObject, obj); }