Unity 3D - IOS设置分辨率问题汇总 : Screen.SetResolution一定要int值,在lua上设置要注意。 在lua上调用Screen.SetResolution传入的number型如果带有小数点,在IOS上会出现 分辨率错乱 问题,环境:(Unity版本2018.3.10f1)。
lua代码 :
--设置分辨率function GameSettingManager:SetResolutionLevel(resolutionLevel) --没有读取到设备宽高 (分辨率) if not DeviceWidth or not DeviceHigh then Logger.Log("不存在设备分辨率") return end local width = DeviceWidth local height = DeviceHigh if ResolutionType.Low == resolutionLevel then local lowRate = 0.5 width = width * lowRate height = height * lowRate elseif ResolutionType.Mid == resolutionLevel then local midRate = 0.8 width = width * midRate height = height * midRate elseif ResolutionType.High == resolutionLevel then --保持原分辨率 end width = math.floor(width) height = math.floor(height) Logger.Log("width : " .. width) Logger.Log("height : " .. height) CS.UnityEngine.Screen.SetResolution(width, height, true)end
Screen.resolutions不可靠