public static XLua.LuaTable LoadMap(string mapName, Action callback = null) { XLua.LuaTable table = (XLua.LuaTable)XLuaManager.OperationTablePool.Alloc(); table.Set("IsDone", false); table.Set("proess", 0); LoadMapInternal(table, mapName, callback); return(table); }
private static async Task LuaLoadUIInternerl(XLua.LuaTable table, UIConfig info) { GameObject result = await Addressables.InstantiateAsync(info.Path).Task; Canvas canvas = result.GetComponent <Canvas>(); canvas.worldCamera = Camera.main; table.Set("Result", result.GetComponent <UIView>().GetUIView()); table.Set("IsDone", true); table.Set("proess", 1); TimeManager.DelayRecycle(table, 1); }
public static XLua.LuaTable LuaLoadUI(int id) { UIConfig uIConfig = UIConfigAsset.Get(id); if (uIConfig != null) { XLua.LuaTable table = (XLua.LuaTable)XLuaManager.OperationTablePool.Alloc(); table.Set("IsDone", false); table.Set("proess", 0); LuaLoadUIInternerl(table, uIConfig); return(table); } else { throw new Exception($"招不到UI路径{id}"); } }
public void LoadLuaString(bool isAssetBundle, string dirType, string scriptName, string scriptPath) { #if HOTFIX_ENABLE scriptEnv = UIManager.luaenv.NewTable(); XLua.LuaTable meta = UIManager.luaenv.NewTable(); meta.Set("__index", UIManager.luaenv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); scriptEnv.Set("self", this); if (dirType == "Resources") { TextAsset luaStr = Resources.Load <TextAsset>(scriptPath); if (luaStr != null) { UIManager.luaenv.DoString(luaStr.text, "LuaUIBehaviour", scriptEnv); } else { Debug.Log(scriptPath + "is null!"); } } else if (dirType == "streamingAssetsPath") { #if UNITY_ANDROID && !UNITY_EDITOR string str = UIFactory.GetAndoidStreamingAssetLuaScripts(scriptName); if (!string.IsNullOrEmpty(str)) { UIManager.luaenv.DoString(str, "LuaUIBehaviour", scriptEnv); } else { Debug.Log(scriptPath + "is null!"); } #else LoadLuaScript(isAssetBundle, dirType, scriptName, scriptPath); #endif } else { LoadLuaScript(isAssetBundle, dirType, scriptName, scriptPath); } scriptEnv.Get("uiFormType", out _luaUiFormType); scriptEnv.Get("OnInit", out luaOnInit); scriptEnv.Get("OnExcute", out luaOnExcute); scriptEnv.Get("OnDisplay", out luaOnDisplay); scriptEnv.Get("OnHide", out luaOnHide); scriptEnv.Get("OnReDisplay", out luaOnReDisplay); scriptEnv.Get("OnFreese", out luaOnFreese); scriptEnv.Get("OnRelease", out luaOnRelease); #endif }
public static async void LoadMapInternal(XLua.LuaTable precess, string mapName, Action callback = null) { m_Env = GameObject.Find("Env"); m_Light = GameObject.Find("Sun").GetComponent <Light>(); //1.加载场景信息 string InfoPath = $"Assets/Art/Scenes/{mapName}/{mapName}/sceneenv.asset"; SceneEnvAsset env = await ResourceManager.LoadAsset(InfoPath) as SceneEnvAsset; string ElementPath = $"Assets/Art/Assets/Scene/{mapName}/{mapName}.asset"; //2.加载地形 SceneElementAsset sceneElements = await ResourceManager.LoadAsset(ElementPath) as SceneElementAsset; List <GameObject> list = await MapManager.LoadPreElement(sceneElements); m_CurrentEnv = env; m_CurrentElements = sceneElements; m_LoadedObjectList.AddRange(list); callback?.Invoke(); //4.优先展示出来基本的灯光、草的环境 Show(true); Name = mapName; //5.最后去异步加载出来场景中的元素 AddSceneElements(); ////3.如果是野外场景需要动态生成导航网格,战斗场景和UI场景不需要 //if (env.sceneType == SceneType.Wild) //{ // LocalNavMeshLoading.Instance.UpdateNavMesh(true); // Debug.Log($"[C#] SceneTree.cs ::load({mapName}) 展示基本灯光、草后开启异步加载场景元素并开始异步烘焙导航网格"); //} callback?.Invoke(); //加载完成, 通知lua precess.Set("IsDone", true); precess.Set("proess", 1); }