@@ -79,6 +79,7 @@ private static void PatchUnityNativeCode(string pathToBuiltProject)
79
79
EditUnityFrameworkH ( Path . Combine ( pathToBuiltProject , "UnityFramework/UnityFramework.h" ) ) ;
80
80
EditUnityAppControllerH ( Path . Combine ( pathToBuiltProject , "Classes/UnityAppController.h" ) ) ;
81
81
EditUnityAppControllerMM ( Path . Combine ( pathToBuiltProject , "Classes/UnityAppController.mm" ) ) ;
82
+ EditUnityViewMM ( Path . Combine ( pathToBuiltProject , "Classes/UI/UnityView.mm" ) ) ;
82
83
}
83
84
84
85
@@ -265,6 +266,43 @@ private static void EditUnityAppControllerMM(string path)
265
266
} ) ;
266
267
}
267
268
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
+
268
306
private static void EditCodeFile ( string path , Func < string , IEnumerable < string > > lineHandler )
269
307
{
270
308
var bakPath = path + ".bak" ;
0 commit comments