|
|
|
|
|
|
return _devicePixelRatio; |
|
|
|
} |
|
|
|
|
|
|
|
if (Application.platform == RuntimePlatform.Android) { |
|
|
|
_devicePixelRatio = DevicePixelRatioAndroid(); |
|
|
|
} else if (Application.platform == RuntimePlatform.WebGLPlayer) { |
|
|
|
_devicePixelRatio = UIWidgetsWebGLDevicePixelRatio(); |
|
|
|
} else if (Application.platform == RuntimePlatform.IPhonePlayer || |
|
|
|
Application.platform == RuntimePlatform.tvOS) { |
|
|
|
_devicePixelRatio = IOSDeviceSaleFactor(); |
|
|
|
} |
|
|
|
#if UNITY_ANDROID
|
|
|
|
_devicePixelRatio = AndroidDevicePixelRatio(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UNITY_WEBGL
|
|
|
|
_devicePixelRatio = UIWidgetsWebGLDevicePixelRatio(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UNITY_IOS
|
|
|
|
_devicePixelRatio = IOSDeviceSaleFactor(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
if (_devicePixelRatio <= 0) { |
|
|
|
_devicePixelRatio = 1; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
static float DevicePixelRatioAndroid() { |
|
|
|
#if UNITY_ANDROID
|
|
|
|
static float AndroidDevicePixelRatio() { |
|
|
|
using ( |
|
|
|
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer") |
|
|
|
) { |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif
|
|
|
|
#if UNITY_WEBGL
|
|
|
|
#endif
|
|
|
|
#if UNITY_IOS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |