I am starting to learn unity and I want to do a method extension to return if the device is retina (not implementing a plugin).
I am trying the following code:
ScreenExtensions.cs
using UnityEngine;
public static class ScreenExtensions {
public static bool isRetina(this Screen scr) {
return ( (Screen.width == 960) ||
(Screen.width == 2048) ||
(Screen.width == 1136) );
}
// public static bool isGiraffe(this Screen scr) { return (Screen.width == 1136); }
}
but it gives me the error message " error CS0117: UnityEngine.Screen' does not contain a definition for isRetina’"
Just place this in your own utility class instead.
Have you completed the method itself btw?
I am also interested in creating a safe isRetina() method, hopefully one that does not need to rely on specific screen resolutions as you may not know what the future brings and you cannot possibly own all the different android devices…
I use to create a new class called _GUI where I always add those kind of stuff like :
deviceType (iphone, iphone 5, ipad) for the ratio type
coefSize (ipad, ipad 3, etc… or iphone3GS, 4, 5, etc… ) for screen scale type. >> ipad 3 (hi-res) is a coef 1.
etc…
From here all my script got an initialization querying my _GUI class.
I completely agree with this approach. The questions we ask should be based on capability and not make-and-model.
The make and model properties, are sometimes the only tool to determine capability, but this should be the last resort.