Merge pull request #27 from krispypen/master

Adding Metal renderer support (on iOS)
This commit is contained in:
Rex Raphael 2019-08-02 13:23:21 +02:00 committed by GitHub
commit 0ba8ae936a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 5 deletions

View File

@ -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`.
<br />
<br />
### Add Unity Build Scripts and Export

View File

@ -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
});
}
/// <summary>
/// Edit 'UnityView.mm': fix the width and height needed for the Metal renderer
/// </summary>
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<string, IEnumerable<string>> lineHandler)
{
var bakPath = path + ".bak";