How do we use iOS.DeviceGeneration?

I’m a bit confused by the docs on this part, and I"m unable to find any sample code. I’m using UnityScript, and so far all my attempts throw errors on compiling.

I’d like to get the “Generation”, such as “iPadAir1” etc, not the model (which would be something like “iPad5,4”)


// This code does not work.
var	generation : iOS.DeviceGeneration	= Device.generation;

You have to compare the current device with the available variables. iOS.Device.generation returns the type of device you are running. Check it against all devices and apply your adjustments as needed.

var iPhone6 : boolean = false;
var iPhone6Plus : boolean = false;

 if(iOS.Device.generation == iOS.DeviceGeneration.Iphone6)
    Debug.Log("I am an Iphone6")
    do your Iphone6 code here. 
    iPhone6 = true;
    iPhone6Plus = false;
    else if(iOS.Device.generation == iOS.DeviceGeneration.Iphone6Plus)
    Debug.Log("I am an Iphone6Plus")
    do your Iphone6Plus code here
    iPhone6 = false;
    iPhone6Plus = true;
    something here for unknown devices or while in editor 
    iPhone6 = false;
    iPhone6Plus = false;

If you are not sure which device generation you have, you can 
Debug.Log("This device is an " + iOS.Device.generation);
The debug will show up in xcode when running your build.

Using UnityEngine.iOS.Device.generation will return one of the following values.

So you want var generation : ? = UnityEngine.iOS.DeviceGeneration;

I’m not sure what the type would be though?