Add UIViewController.view to Unity view

Hi, it’s been a few years since I let needed to add a custom view controller on top of the Unity view. It used to be I could call:

UIWindow *window = [[[UIApplication sharedApplication] keyWindow];
UIViewController *theController = window.rootViewController;

And attach my view controller’s view to that. But now I am seeing that window as nil. Is there a newer way to do this?

I see. UnityGetGLViewController() seems to be the current flavor.

[UnityGetGLViewController().view addSubview:customView];

A quick way to do this is to load your view from a .xib, set its frame, and add it to Unity’s view with the above line.