Skip to content

Double activation return system ​

On iOS devices, when the user returns to the home screen through a slide-up gesture, the immersion experience of the game may sometimes be affected. In order to improve the user experience, we need to add Home slide up twice in the game to activate the return system function.

Core code ​

objective-c
-(UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
Return UIRectEdgeAll;
}

Unity Game Implementation Location ​

1. In the exported Xcode project, globally search for the following keywords:preferredScreenEdgesDeferringSystemGestures 2, inUnityViewControllerBaseorUnityAppController.mmFind the following code

objective-c
-(UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
UIRectEdge res = UIRectEdgeNone;
If (UnityGetDeferSystemGesturesTopEdge())
Res | = UIRectEdgeTop;
If (UnityGetDeferSystemGesturesBottomEdge())
Res | = UIRectEdgeBottom;
If (UnityGetDeferSystemGesturesLeftEdge())
Res | = UIRectEdgeLeft;
If (UnityGetDeferSystemGesturesRightEdge())
Res | = UIRectEdgeRight;
Return res;
}

3. The code is modified as follows

objective-c
-(UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
Return UIRectEdgeAll;
}

Note: If the global search in the project is not available.preferredScreenEdgesDeferringSystemGestures, you need to be in the game's main controller (that is, the host rendering view.UIViewController, is usuallyGameViewController,RootViewControllerOr Unity.UnityViewControllerBase) to implement the method. This ensures that the entire game interface uniformly enables the delay trigger mechanism of system edge gestures, effectively reduces interaction interruption caused by false touch, and improves immersive experience.