@@ -79,6 +79,7 @@ private static void PatchUnityNativeCode(string pathToBuiltProject)
7979 EditUnityFrameworkH ( Path . Combine ( pathToBuiltProject , "UnityFramework/UnityFramework.h" ) ) ;
8080 EditUnityAppControllerH ( Path . Combine ( pathToBuiltProject , "Classes/UnityAppController.h" ) ) ;
8181 EditUnityAppControllerMM ( Path . Combine ( pathToBuiltProject , "Classes/UnityAppController.mm" ) ) ;
82+ EditUnityViewMM ( Path . Combine ( pathToBuiltProject , "Classes/UI/UnityView.mm" ) ) ;
8283 }
8384
8485
@@ -265,6 +266,43 @@ private static void EditUnityAppControllerMM(string path)
265266 } ) ;
266267 }
267268
269+ /// <summary>
270+ /// Edit 'UnityView.mm': fix the width and height needed for the Metal renderer
271+ /// </summary>
272+ private static void EditUnityViewMM ( string path )
273+ {
274+ var inScope = false ;
275+
276+ // Add frameworkWarmup method
277+ EditCodeFile ( path , line =>
278+ {
279+ inScope |= line . Contains ( "UnityGetRenderingResolution(&requestedW, &requestedH)" ) ;
280+
281+ if ( inScope )
282+ {
283+ if ( line . Trim ( ) == "" )
284+ {
285+ inScope = false ;
286+
287+ return new string [ ]
288+ {
289+ "" ,
290+ "// Added by " + TouchedMarker ,
291+ " if (requestedW == 0) {" ,
292+ " requestedW = _surfaceSize.width;" ,
293+ " }" ,
294+ " if (requestedH == 0) {" ,
295+ " requestedH = _surfaceSize.height;" ,
296+ " }" ,
297+ ""
298+ } ;
299+ }
300+ }
301+
302+ return new string [ ] { line } ;
303+ } ) ;
304+ }
305+
268306 private static void EditCodeFile ( string path , Func < string , IEnumerable < string > > lineHandler )
269307 {
270308 var bakPath = path + ".bak" ;
0 commit comments