| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- --[[
- Tips:
- EffectType: LeftTop/LeftBottom/RightTop/RightBottom
- ]]
- local DemoPage = {}
- local function RefreshUI()
- local tPageInfo = {
- ["tImgPath"] = {
- "CommonUtils/Textures/Page/page0.png",
- "CommonUtils/Textures/Page/page1.png",
- "CommonUtils/Textures/Page/page2.png",
- "CommonUtils/Textures/Page/page3.png",
- "CommonUtils/Textures/Page/page4.png",
- "CommonUtils/Textures/Page/page5.png",
- },
- ["szImgBG"] = "CommonUtils/Textures/Page/P0_Back.png",
- ["szShadowLeft"] = "CommonUtils/Textures/Page/shadow.png",
- ["szShadowRight"] = "CommonUtils/Textures/Page/shadowLTR.png",
- ["nShadowWidth"] = 50,
- ["nEffectTime"] = 0.5,
- ["leftEffectType"] = "LeftBottom",
- ["rightEffectType"] = "RightBottom"
- }
- SetCache("PAGE_INFO", tPageInfo)
- local pageObj = DemoPage.rootPanel.transform:Find("Page").gameObject
- local uiHelper = require('Base/UIHelper.lua')
- local szPagePath = "CommonUtils/Page/Page.lua"
- uiHelper:AddScript(pageObj, szPagePath)
- require(szPagePath).Init()
- end
- local function CheckInput()
- if not CS.UnityEngine.Application.isEditor then
- return
- end
- local Input = CS.UnityEngine.Input
- local KeyCode = CS.UnityEngine.KeyCode
- local eventManager = require('Base/ZEventDispatchCenter.lua')
- if Input.GetKeyDown(KeyCode.A) then
- eventManager:DispatchEvent(eventManager.EventType.COMMON_UI_PAGE_PRE)
- return
- end
- if Input.GetKeyDown(KeyCode.D) then
- eventManager:DispatchEvent(eventManager.EventType.COMMON_UI_PAGE_NEXT)
- return
- end
- end
- local function OnClickBtnExit()
- require("Base/UIHelper.lua"):SwitchUI("CommonUtils/DemoLuaScripts/DemoAll.lua", "CommonUtils/DemoLuaScripts/DemoPage.lua")
- end
- local function RegisterTouchEvent()
- local uiHelper = require("Base/UIHelper.lua")
- local rootPanel = DemoPage.rootPanel
- uiHelper:AddClickEvent(rootPanel, "Btn_Exit", OnClickBtnExit)
- end
- local function UnInitPage()
- require("CommonUtils/Page/Page.lua").UnInit()
- end
- function DemoPage.Awake(luaRoot)
- DemoPage.luaRoot = luaRoot
- local canvas = CS.UnityEngine.GameObject.Find('Canvas')
- DemoPage._rootCanvas = canvas
- local prefabPage = LoadResource("CommonUtils/Prefabs/Demo/ZDemoPagePanel.prefab")
- local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPage, canvas.transform)
- DemoPage.rootPanel = rootPanel
- end
- function DemoPage.Start()
- RefreshUI()
- RegisterTouchEvent()
- end
- function DemoPage.Update()
- CheckInput()
- end
- function DemoPage.OnDestroy()
- UnInitPage()
- CS.UnityEngine.GameObject.Destroy(DemoPage.rootPanel)
- end
- return DemoPage
|