fzhangtj
6 年前
当前提交
d9da1de6
共有 9 个文件被更改,包括 318 次插入 和 9 次删除
-
22Runtime/engine/WidgetCanvas.cs
-
8Runtime/Plugins.meta
-
58Runtime/engine/DisplayMetrics.cs
-
11Runtime/engine/DisplayMetrics.cs.meta
-
8Runtime/Plugins/DeviceScreen.mm
-
104Runtime/Plugins/DeviceScreen.mm.meta
-
7Runtime/Plugins/webgl.jslib
-
109Runtime/Plugins/webgl.jslib.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 748885407ae664e1093421099f1ad4b6 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Runtime.InteropServices; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.engine { |
|||
|
|||
public class DisplayMetrics { |
|||
|
|||
static float _devicePixelRatio = 0; |
|||
|
|||
public static float devicePixelRatio { |
|||
get { |
|||
if (_devicePixelRatio > 0) { |
|||
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 (_devicePixelRatio <= 0) { |
|||
_devicePixelRatio = 1; |
|||
} |
|||
|
|||
return _devicePixelRatio; |
|||
} |
|||
|
|||
} |
|||
|
|||
static float DevicePixelRatioAndroid() { |
|||
using ( |
|||
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer") |
|||
) { |
|||
using ( |
|||
AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"), |
|||
activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"), |
|||
windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"), |
|||
displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay") |
|||
) { |
|||
displayInstance.Call("getMetrics", metricsInstance); |
|||
return metricsInstance.Get<float>("density"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[DllImport("__Internal")] |
|||
static extern float UIWidgetsWebGLDevicePixelRatio(); |
|||
|
|||
[DllImport("__Internal")] |
|||
static extern int IOSDeviceSaleFactor(); |
|||
|
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6427f06ce097c4650a5aaa5b9ecb41bf |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <UIKit/UIKit.h> |
|||
extern "C" |
|||
{ |
|||
int IOSDeviceSaleFactor() |
|||
{ |
|||
return [[UIScreen mainScreen] scale]; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 349072cdca47948b89f3e8cfab33f642 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
platformData: |
|||
- first: |
|||
'': Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Android: 1 |
|||
Exclude Editor: 1 |
|||
Exclude Linux: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude LinuxUniversal: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
Exclude iOS: 0 |
|||
- first: |
|||
Android: Android |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: ARMv7 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
DefaultValueInitialized: true |
|||
OS: AnyOS |
|||
- first: |
|||
Facebook: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Facebook: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Linux |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86 |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: OSXUniversal |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: |
|||
AddToEmbeddedBinaries: false |
|||
CompileFlags: |
|||
FrameworkDependencies: |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
mergeInto(LibraryManager.library, { |
|||
|
|||
UIWidgetsWebGLDevicePixelRatio: function () { |
|||
return window.devicePixelRatio || 1; |
|||
}, |
|||
|
|||
}); |
|
|||
fileFormatVersion: 2 |
|||
guid: 7d896da6a0e454594a11916493dae285 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
platformData: |
|||
- first: |
|||
'': Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Android: 1 |
|||
Exclude Editor: 1 |
|||
Exclude Linux: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude LinuxUniversal: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude WebGL: 0 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
Exclude iOS: 1 |
|||
- first: |
|||
Android: Android |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: ARMv7 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
DefaultValueInitialized: true |
|||
OS: AnyOS |
|||
- first: |
|||
Facebook: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
Facebook: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Facebook: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Linux |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86 |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: OSXUniversal |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
WebGL: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
AddToEmbeddedBinaries: false |
|||
CompileFlags: |
|||
FrameworkDependencies: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue