1 Star 6 Fork 2

鲤鱼/unity_frame_lua

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.lua 3.51 KB
一键复制 编辑 原始数据 按行查看 历史
鲤鱼 提交于 2023-06-12 17:27 . .
require "base/setup"
function Main()
LogInfo("当前平台:"..tostring(Application.platform))
LogInfof("屏幕宽:%s,高:%s", Screen.width, Screen.height)
InitSetting()
InitObject()
Hotswap()
InitClass()
GameManager.Instance:Start()
end
function InitObject()
GameObject.DontDestroyOnLoad(GameObject.Find("EventSystem"))
UIDefine.canvasRoot = GameObject.Find("Canvas").transform
GameObject.DontDestroyOnLoad(UIDefine.canvasRoot.gameObject)
local size = UIDefine.canvasRoot.sizeDelta
KvData.curScreenWidth = size.x
KvData.curScreenHeight = size.y
local mixedObj = GameObject("mixed")
mixedObj:AddComponent(RectTransform)
mixedObj.transform:SetParent(UIDefine.canvasRoot)
mixedObj.transform:Reset()
mixedObj.transform:SetSizeDelata(0,0)
local calcPosNode = GameObject("calc_pos_node")
calcPosNode:AddComponent(RectTransform)
calcPosNode.transform:SetParent(mixedObj.transform)
mixedObj.transform:Reset()
mixedObj.transform:SetSizeDelata(0,0)
UIDefine.calcPosNode = calcPosNode.transform
UIDefine.uiCamera = GameObject.Find("UICamera"):GetComponent(Camera)
GameObject.DontDestroyOnLoad(UIDefine.uiCamera.gameObject)
KvData.mainCamera = GameObject.Find("MainCamera"):GetComponent(Camera)
GameObject.DontDestroyOnLoad(KvData.mainCamera.gameObject)
end
function Hotswap()
if VersionUpdater.Instance.hotswap ~= "" then
local hotswapContent = string.format("<----------\n%s\n---------->",VersionUpdater.Instance.hotswap)
LogInfo("hotswap内容:\n"..hotswapContent)
require("hotswap")
end
end
function InitClass()
GameManager.New()
end
function ModuleSetup(module)
local class = GetClass(module)
if class == nil then LogErrorf("无法找到模块入口[%s]",module) return end
local facade = class.New(class)
end
function Update()
GameManager.Instance:Update()
end
function LateUpdate()
GameManager.Instance:LateUpdate()
end
function OnApplicationFocus(flag)
GameManager.Instance:OnApplicationFocus(flag)
end
function OnApplicationQuit()
GameManager.Instance:OnApplicationQuit()
end
function InitPlatform()
end
function InitSetting()
KvData.luaDebug = BaseSetting.debug and BaseSetting.luaDebug
if Application.platform == RuntimePlatform.Android then
KvData.platform = KvData.PlatformType.Android
elseif Application.platform == RuntimePlatform.IPhonePlayer then
KvData.platform = KvData.PlatformType.IPhonePlayer
elseif Application.platform == RuntimePlatform.WindowsEditor then
KvData.platform = KvData.PlatformType.WindowsEditor
IS_DEBUG = true
IS_EDITOR = true
elseif Application.platform == RuntimePlatform.OSXEditor then
KvData.platform = KvData.PlatformType.OSXEditor
IS_DEBUG = true
IS_EDITOR = true
elseif Application.platform == RuntimePlatform.OSXPlayer then
KvData.platform = KvData.PlatformType.OSXPlayer
IS_DEBUG = true
elseif Application.platform == RuntimePlatform.WindowsPlayer then
KvData.platform = KvData.PlatformType.WindowsPlayer
IS_DEBUG = true
elseif Application.platform == RuntimePlatform.WebGLPlayer then
KvData.platform = KvData.PlatformType.WebGLPlayer
IS_DEBUG = true
end
if not IS_DEBUG then
IS_DEBUG = PlayerPrefsEx.GetInt("IS_DEBUG",0) > 0
end
IS_DEBUG = true
if IS_DEBUG then
LuaManager.logObj:SetActive(true)
end
--TODO:调试阶段,先开启
--IS_DEBUG = true
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Lua
1
https://gitee.com/carp3010/unity_frame_lua.git
git@gitee.com:carp3010/unity_frame_lua.git
carp3010
unity_frame_lua
unity_frame_lua
master

搜索帮助