Example #1
0
        public static void Init()
        {
            var ui = GameObject.Find("Canvas");

            Log.ErrorIf(!ui, "not found Canvas");
            _root = ui.transform;
            InitLayer();
            UIConfig.LoadUIConfig();
        }
        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}");
            }
        }