源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

106 linhas
3.2 KiB

LuaState = LuaState or BaseClass(BaseView)
function LuaState:__init()
self.base_file = "luaState"
self.layout_file = "luaState"
self.layer_name = "Top"
self.all_count = 0
self.all_fps = 0
self.server_list = {}
self.load_callback = function ()
self:LoadSuccess()
self:InitEvent()
end
self.open_callback = function ()
end
self.close_callback = function ()
end
self.destroy_callback = function ()
self:Remove()
end
end
function LuaState:Remove()
if self.update_id then
GlobalEventSystem:UnBind(self.update_id)
self.update_id = nil
end
if self.story_start_id then
GlobalEventSystem:UnBind(self.story_start_id)
self.story_start_id = nil
end
if self.story_finish_id then
GlobalEventSystem:UnBind(self.story_finish_id)
self.story_finish_id = nil
end
if self.scene_complete_id then
GlobalEventSystem:UnBind(self.scene_complete_id)
self.scene_complete_id = nil
end
end
function LuaState:LoadSuccess()
self.transform.localPosition = Vector3(-ScreenWidth / 2 + 500, ScreenHeight/2)
self.memText = self:GetChild("memText"):GetComponent("Text")
end
function LuaState:Update(now_time, elapse_time)
self:SetContent()
end
function LuaState:SetContent()
self.all_count = self.all_count + 1
self.all_fps = self.all_fps + LuaFPS.FPS
local temp_str = string.format("mem: %.0f k\nmemlevel: %d\nfps: %d\navgfps: %.1f", collectgarbage("count"), SystemMemoryLevel.Cur, LuaFPS.FPS, self.all_fps/self.all_count)
-- local role_angle = MainRole.role_from_camera_angle or 0
-- local camera_angle = MainRole.camera_cur_angle or 0
-- local temp_str = string.format("mem: %.0f k\nmemlevel: %d\nrole: %d\ncamera: %.1f", collectgarbage("count"), SystemMemoryLevel.Cur, role_angle, camera_angle)
self.memText.text = "<color='#00ff00'>"..temp_str.."</color>"
end
function LuaState:InitEvent()
local function onUpdate()
self:SetContent()
end
self.update_id = GlobalEventSystem:Bind(EventName.SET_FPS,onUpdate)
onUpdate()
local function on_reset( )
self.all_count = 0
self.all_fps = 0
self:SetContent()
end
self.scene_complete_id = GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, on_reset)
-- local function onStoryStart()
-- local UI = panelMgr:GetParent("UI")
-- self.transform:SetParent(UI)
-- SetLocalScale(self.transform)
-- SetAnchoredPosition(self.transform, -310,340)
-- end
-- self.story_start_id = GlobalEventSystem:Bind(EventName.STORY_START,onStoryStart)
-- local function onStoryFinish()
-- local Top = panelMgr:GetParent("Top")
-- self.transform:SetParent(Top)
-- SetLocalScale(self.transform)
-- SetAnchoredPosition(self.transform, -310,340)
-- end
-- self.story_finish_id = GlobalEventSystem:Bind(EventName.STORY_FINISH,onStoryFinish)
end
-- function LuaState:SetContent()
-- local str = [[
-- <color="#00ff00">FPS:{0}</color>
-- dc:{1}
-- batch:{2}
-- tri:{3}
-- ver:{4}
-- dbDC:{5}
-- dbt:{6}
-- ]]
-- local u_stats = UnityEditor.UnityStats
-- self.memText.text = string.format("lua mem:%.2fk\n", collectgarbage("count")) .. Language.substitute(str, LuaFPS.FPS, u_stats.drawCalls, u_stats.batches,
-- u_stats.triangles, u_stats.vertices, u_stats.dynamicBatchedDrawCalls, u_stats.dynamicBatches)
-- end