예제 #1
0
        protected override void OnBeforDestroy()
        {
            base.OnBeforDestroy();
            if (onBeforDestroy != null)
            {
                onBeforDestroy();
            }

            onInit         = null;
            onOpen         = null;
            onClose        = null;
            onBeforDestroy = null;

            int len = m_LuaComs.Length;

            for (int i = 0; i < len; i++)
            {
                LuaCom com = m_LuaComs[i];
                com.Trans = null;
                com       = null;
            }
            //卸载图片资源
            // int len = m_LuaComs.Length;
            // for (int i = 0; i < len; i++)
            // {
            //     LuaCom com = m_LuaComs[i];
            //
            //     switch (com.Type)
            //     {
            //         case LuaComType.Button:
            //         case LuaComType.Image:
            //         case LuaComType.YouYouImage:
            //             {
            //                 Image img = com.Trans.GetComponent<Image>();
            //                 img.sprite = null;
            //             }
            //             break;
            //         case LuaComType.RawImage:
            //             {
            //                 RawImage img = com.Trans.GetComponent<RawImage>();
            //                 img.texture = null;
            //             }
            //             break;
            //     }
            //
            //     com.Trans = null;
            //     com = null;
            // }
        }
예제 #2
0
        /// <summary>
        /// 根据索引来查找组件
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public object GetLuaComs(int index)
        {
            LuaCom com = m_LuaComs[index];

            switch (com.Type)
            {
            case LuaComType.GameObject:
                return(com.Trans.gameObject);

            case LuaComType.Transform:
                return(com.Trans);

            case LuaComType.Button:
                return(com.Trans.GetComponent <Button>());

            case LuaComType.Image:
                return(com.Trans.GetComponent <Image>());

            case LuaComType.YouYouImage:
                return(com.Trans.GetComponent <YouYouImage>());

            case LuaComType.Text:
                return(com.Trans.GetComponent <Text>());

            case LuaComType.YouYouText:
                return(com.Trans.GetComponent <YouYouText>());

            case LuaComType.RawImage:
                return(com.Trans.GetComponent <RawImage>());

            case LuaComType.InputField:
                return(com.Trans.GetComponent <InputField>());

            case LuaComType.Scrollbar:
                return(com.Trans.GetComponent <Scrollbar>());

            case LuaComType.ScrollView:
                return(com.Trans.GetComponent <ScrollRect>());

            case LuaComType.MulityScroller:
                return(com.Trans.GetComponent <UIMultiScroller>());
            }

            return(com.Trans);
        }