We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe5536c commit c5b1f7fCopy full SHA for c5b1f7f
Demo/API_V2/Assets/Scripts/GameManager.cs
@@ -71,13 +71,12 @@ private void Awake()
71
);
72
73
// 获取微信小游戏的系统信息
74
-#if UNITY_WEBGL && !UNITY_EDITOR
75
WindowInfo = WX.GetWindowInfo();
76
MenuButtonBoundingClientRect = WX.GetMenuButtonBoundingClientRect();
77
-#else
78
- WindowInfo = new WindowInfo { safeArea = new SafeArea() };
79
- MenuButtonBoundingClientRect = new ClientRect();
80
-#endif
+
+ // 非小游戏与预览环境下防止报错
+ WindowInfo ??= new WindowInfo { safeArea = new SafeArea() };
+ MenuButtonBoundingClientRect ??= new ClientRect();
81
}
82
83
0 commit comments