Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Controlling Resolution on ATV4 vs ATV4K

Discussion in 'iOS and tvOS' started by Xander-Davis, Dec 19, 2019.

  1. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Hi!

    I have a Platform Manager script I've created that can detect which platform (such as iOS vs tvOS) and sets the resolution accordingly to maximize performance.

    Just like how we can get platform, is there a way to get which device generation between Apple TV 4 and Apple TV 4K so I can set a boolean and then do an if/then to route & set resolution accordingly? How can this be done?

    For performance reasons, I need to set a lower resolution on ATV4 but want a higher res for ATV4K.

    Thanks for your insight!
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,899
    Xander-Davis likes this.
  3. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Thanks! I'll look into this and give it a try!
     
  4. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    It seems Unity's device check doesn't actually work.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class AstrogunPlatformManager : MonoBehaviour {
    4.  
    5.     // Apple TV Generation
    6.     private     bool                atv4        =   false;
    7.     private     bool                atv4k       =   false;
    8.  
    9.     // init
    10.     void Start ()
    11.     {
    12.  
    13. #if UNITY_TVOS
    14.  
    15.         Debug.Log("Astrogun Platform Manager: Settting for tvOS");
    16.  
    17.         if (UnityEngine.tvOS.Device.generation == UnityEngine.tvOS.DeviceGeneration.AppleTV1Gen)
    18.         {
    19.             Debug.Log("Astrogun Platform Manager: Current Device: Apple TV 4");
    20.             atv4 = true;
    21.             atv4k = false;
    22.         }
    23.         else if(UnityEngine.tvOS.Device.generation == UnityEngine.tvOS.DeviceGeneration.AppleTV1Gen)
    24.         {
    25.             Debug.Log("Astrogun Platform Manager: Current Device: Apple TV 4K");
    26.             atv4 = false;
    27.             atv4k = true;
    28.         }
    29.  
    30.         Debug.Log("Astrogun Platform Manager: Final Device Check: ATV4:" + atv4);
    31.         Debug.Log("Astrogun Platform Manager: Final Device Check: ATV4K:" + atv4k);
    32. }
    Both atv4 & atv4k return false.

    It is worth noting that Unity erroneously calls the ATV4 'Apple TV 1' and the ATV4K 'Apple TV 2'. Technically the ATV4K is the Apple TV 5. But whatever. They're obviously resetting the count from the first Apple TV device to have tvOS (Apple TV 4), but Unity would be the only ones to do that.

    Also curiously, in line code, I couldn't use the Device Generation tags for anything unless I added 'UnityEngine' first even though I'm already designating 'using UnityEngine;' at the top.

    Anyone have any ideas why this wouldn't work?

    Or am I missing something? I hope I'm just missing something...

    ~

    Using 'SystemInfo.graphicsDeviceVendor', we get 'Apple A8 GPU' on ATV4 and 'Apple A10X GPU' on ATV4K. At this point I'm guessing this technique will work instead.
     
    Last edited: Dec 22, 2019
  5. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Update: Yep, using 'SystemInfo.graphicsDeviceVendor' worked instead. Thanks @AcidArrow !
     
    Last edited: Dec 22, 2019
    AcidArrow likes this.
  6. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,386
    One issue I noticed in your code is the if and else if statements both refer to AppleTV1Gen.

    Have you tried Debug.Log(UnityEngine.tvOS.Device.generation); to see what it returns?
     
    Xander-Davis likes this.
  7. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Good catch-- I'll try it again and try the debug log too
     
unityunity