Adding Metal renderer support (on iOS)
This commit is contained in:
parent
fe0801aef7
commit
4bf72c06a6
|
@ -80,13 +80,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
|
||||
|
|
|
@ -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";
|
||||
|
|
Reference in New Issue