Ejemplo n.º 1
0
        /// <summary>
        /// 初始化UI数据
        /// 调用Lua初始化;
        /// </summary>
        /// <param name="uiName"></param>
        /// <param name="go"></param>
        private void InitUI(string uiName, GameObject go, object[] args)
        {
            go.transform.SetParent(UIRoot);
            go.transform.ResetTransform();
            RectTransform rt = go.transform.GetComponent <RectTransform>();

            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector2.one;
            rt.pivot     = Vector2.one * 0.5f;
            rt.offsetMin = Vector2.zero;
            rt.offsetMax = Vector2.zero;

            go.SetActive(true);
            var canvas = go.GetComponent <Canvas>();

            if (canvas != null)
            {
                orderIndex            += orderInterval;
                canvas.overrideSorting = true;
                canvas.sortingLayerID  = SortingLayer.NameToID("Default");
                canvas.sortingOrder    = orderIndex;
            }
            string luaViewName = UIViewUtils.GetLuaViewName(uiName);

            PanelBridge.SetPanelData(go.GetInstanceID(), uiName, args);
            PanelBridge panelBridge = go.AddComponent <PanelBridge>();

            mPanelStack.Push(panelBridge);
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            int instanceId = gameObject.GetInstanceID();

            string uiName = uiInfoDict[instanceId];

            uiInfoDict.RemoveKey(instanceId);
            UIName = uiName;

            object[] uiData = uiDataDict[instanceId];
            uiDataDict.RemoveKey(instanceId);

            string luaViewClsName = UIViewUtils.GetLuaViewName(uiName);
            Func <GameObject, object[], LuaTable> ctorFunc = GameMain.GetInstance().GetGlobalTable().GetInPath <Func <GameObject, object[], LuaTable> >(luaViewClsName + ".New");

            LuaViewCls = ctorFunc(gameObject, uiData);
            InitLuaFunction();

            if (LuaAwake != null)
            {
                LuaAwake.Action <LuaTable>(LuaViewCls);
            }
        }