Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Rendering UNITY in Safe Area of IOS.

Discussion in 'Editor & General Support' started by DraCieLisAWAL, Jan 4, 2024.

  1. DraCieLisAWAL

    DraCieLisAWAL

    Joined:
    Jan 18, 2020
    Posts:
    4
    Hi,
    I have an application in IOS that loads Unity. Now, when Unity is loaded, I want it to be rendered in Safe Area (not just some part of UI BUT WHOLE UNITY - it's a 3d Game). The game is already developed and I want it to render in the safe area only.
    I have tried the safe area script and it just helps in bringing UI elements in the safe area. Is there any way I can render whole of the Unity in the safe area. Really need this as with Iphone 15 onwards, dynamic island is really hampering my game's performance.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    Do you have Unity embedded in a native iOS app? If so, you can set the view size of the Unity content accordingly. You still have to display a frame or something, not just leaving the borders black - most likely Apple will reject such apps as this is a clear sign of low quality and rather unexpected for users (they may regard it as a bug).

    If you use Unity in the regular way (not embedded) then it will always render to fullscreen.
    Since you're having performance issues, reducing the view size is not the solution in this case. Profile the game on the device to learn what is affecting performance the most and then find ways to optimize that.

    A common way on desktop to reduce the rendering load is to render at a lower resolution and then upscale the image. This is typicaly called "renderscale" and quite helpful if the game is GPU bound. I don't know if this is a setting available for iOS but it should be if you use Universal Render Pipeline.

    If you are using builtin render pipeline on mobile you're leaving performance untapped.
     
    ABCodeworld likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,988
    You can have black borders equal to the safe area, so you don't render stuff there, but Apple will most probably won't accept it.

    There is also no renderscale setting in iOS.

    Also built-in is probably still faster on mobile that URP in many use cases, not sure if your game falls into one of them or not.

    Finally: iPhone 15 was shown running Resident Evil 4 Remake, if you have performance issues on this device you're probably doing something wrong.
     
  4. DraCieLisAWAL

    DraCieLisAWAL

    Joined:
    Jan 18, 2020
    Posts:
    4
    Correcting myself here, I meant hampering game's visuals and not performance.
     
  5. DraCieLisAWAL

    DraCieLisAWAL

    Joined:
    Jan 18, 2020
    Posts:
    4
    Quoting from Unity as a library github read me file, Unity supports rendering only full screen. Can't really find how to solve this.
    upload_2024-1-5_14-54-40.png
     
  6. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    413
    Change your camera view settings so that things you want to be inside the safe areas are inside the safe areas.

    Do your own masking and put black UI overlay on top to hide things in the safe area.

    You might be able to do it with the camera viewport values as well. But you will have to probably calculate these based on the phone you are on. You may still need an additional camera to clear the full screen background each frame. Can be set to an earlier priority and set to render no layers.

    Not sure if your question was performance related or not, but you can always render to a render texture then copy that to the screen inset. Then you can control the actual render resolution vs the screen resolution. I think now its easier to get AA and other features when rendering to the RT.