diff --git a/README.md b/README.md index 29e5b31..7c86988 100644 --- a/README.md +++ b/README.md @@ -81,13 +81,9 @@ Be sure you have at least one scene added to your build. **iOS Platform**: 1. This only works with Unity version >=2019.3 because uses Unity as a library! - 2. Other Settings find the Rendering part, uncheck the `Auto Graphics API` and select only `OpenGLES3`. - 3. Depending on where you want to test or run your app, (simulator or physical device), you should select the appropriate SDK on `Target SDK`. + 2. Depending on where you want to test or run your app, (simulator or physical device), you should select the appropriate SDK on `Target SDK`.
- - -
### Add Unity Build Scripts and Export diff --git a/scripts/Editor/XCodePostBuild.cs b/scripts/Editor/XCodePostBuild.cs index 9ae503a..d9176a2 100644 --- a/scripts/Editor/XCodePostBuild.cs +++ b/scripts/Editor/XCodePostBuild.cs @@ -79,6 +79,7 @@ public static class XcodePostBuild EditUnityFrameworkH(Path.Combine(pathToBuiltProject, "UnityFramework/UnityFramework.h")); EditUnityAppControllerH(Path.Combine(pathToBuiltProject, "Classes/UnityAppController.h")); EditUnityAppControllerMM(Path.Combine(pathToBuiltProject, "Classes/UnityAppController.mm")); + EditUnityViewMM(Path.Combine(pathToBuiltProject, "Classes/UI/UnityView.mm")); } @@ -265,6 +266,43 @@ public static class XcodePostBuild }); } + /// + /// Edit 'UnityView.mm': fix the width and height needed for the Metal renderer + /// + private static void EditUnityViewMM(string path) + { + var inScope = false; + + // Add frameworkWarmup method + EditCodeFile(path, line => + { + inScope |= line.Contains("UnityGetRenderingResolution(&requestedW, &requestedH)"); + + if (inScope) + { + if (line.Trim() == "") + { + inScope = false; + + return new string[] + { + "", + "// Added by " + TouchedMarker, + " if (requestedW == 0) {", + " requestedW = _surfaceSize.width;", + " }", + " if (requestedH == 0) {", + " requestedH = _surfaceSize.height;", + " }", + "" + }; + } + } + + return new string[] { line }; + }); + } + private static void EditCodeFile(string path, Func> lineHandler) { var bakPath = path + ".bak";