Unity全面屏适配 IOS

Unity 全面屏适配

  • 修改 xcode 方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
string src = @"    _window         = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];";

string dst = @"// _window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];

CGRect winSize = [UIScreen mainScreen].bounds;
if (winSize.size.width / winSize.size.height > 2) {
winSize.size.width -= 64;
winSize.origin.x = 32;
}
_window = [[UIWindow alloc] initWithFrame: winSize];

";
string unityAppControllerPath = path + "/Classes/UnityAppController.mm";
XClassExt UnityAppController = new XClassExt (unityAppControllerPath);
UnityAppController.Replace (src, dst);
  • 修改 UGUI 方法