Search Unity

Cinemachine framing with Screen.safeArea?

Discussion in 'Cinemachine' started by makeshiftwings, Mar 22, 2021.

  1. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I'm using a Cinemachine Target Group and a Framing Transposer to frame some objects with the camera. That's all working well. But I'm wondering if there's any way to integrate the Screen.safeArea so that I can deal with things like the dreaded iPhone notch; I would like it to ideally zoom out enough that everything in the Target Group is within the safe area, with nothing covered by the notch.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If your Follow target is a CinemachineTargetGroup, then FramingTransposer will have Group Framing options. You can set how much of the screen you want your target to occupy:

    upload_2021-3-22_11-6-55.png
     
  3. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I've seen that, but I was hoping there was a way to automatically adjust that based on Screen.safeArea. For example, on a normal phone without a notch, I would like that to be 1, to take up the entire screen. But on an iPhone with a notch, I'd like it to be whatever is required to have it line up with the edge of the notch. Similarly for other phones with Screen.safeArea issues like iPhones with the menu button on the side. Also, it would be useful if there was a way to specify separate X and Y values for how much of the screen to fill. Like for the notch screen in landscape mode, I'd want something like 0.9 of the horizontal space but 1.0 of the vertical space to be filled.
     
    bobbaluba likes this.
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Unfortunately there is no automatic feature for this. You'll have to write a script to check Screen.safeArea and set it up manually. Similarly, you can write a script to dynamically adjust it to get the framing you want, to work around the fact there there are not separate controls for horizontal and vertical framing.
     
  5. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Ah, oh well. I would highly recommend adding some kind of built-in support for Screen.safeArea to Cinemachine at some point, or at least an easier way to specify a view area in screen coordinates for the camera to work with, as I think this will become a common problem as Apple continues to make weirder shaped screens. God help us all the day they decide to make an iPhone Trapezoid. :D
     
    bobbaluba likes this.
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    iPhone Sphere !
     
    makeshiftwings likes this.