Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A sub-classed UnityAppController that allows a tvOS application to be manually suspended, to circumvent Unity issue #1134856. To use, place both files in a Plugin/tvOS folder in your Unity project and call UnityEngine.tvOS.Application.ExitToHomeScreen to suspend the application.
#if UNITY_TVOS
namespace UnityEngine
{
namespace tvOS
{
public class Application
{
[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public void ExitToHomeScreen();
}
}
}
#endif
#import "UnityAppController.h"
@interface SuspendableAppController : UnityAppController
-(void) exitToHomeScreen;
@end
static SuspendableAppController* delegateObject;
@implementation SuspendableAppController
-(void) startUnity: (UIApplication*) application {
[super startUnity: application];
delegateObject = self;
}
-(void) exitToHomeScreen {
UIApplication *app = [UIApplication sharedApplication];
[app performSelector:@selector(suspend)];
}
extern "C" {
void ExitToHomeScreen() {
[delegateObject exitToHomeScreen];
}
}
@end
IMPL_APP_CONTROLLER_SUBCLASS( SuspendableAppController )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.