Skip to content

Commit c5b1f7f

Browse files
committed
Update GameManager.cs
1 parent fe5536c commit c5b1f7f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Demo/API_V2/Assets/Scripts/GameManager.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ private void Awake()
7171
);
7272

7373
// 获取微信小游戏的系统信息
74-
#if UNITY_WEBGL && !UNITY_EDITOR
7574
WindowInfo = WX.GetWindowInfo();
7675
MenuButtonBoundingClientRect = WX.GetMenuButtonBoundingClientRect();
77-
#else
78-
WindowInfo = new WindowInfo { safeArea = new SafeArea() };
79-
MenuButtonBoundingClientRect = new ClientRect();
80-
#endif
76+
77+
// 非小游戏与预览环境下防止报错
78+
WindowInfo ??= new WindowInfo { safeArea = new SafeArea() };
79+
MenuButtonBoundingClientRect ??= new ClientRect();
8180
}
8281
);
8382
}

0 commit comments

Comments
 (0)