unity3d - Android DisplayMetrics inconsistent between devices -


i'm trying use dpi , touch input in unity game recognise gestures consistently across android devices of different sizes.

for instance, want virtual thumbstick 2 inches "full left" "full right". given dpi of screen, can convert touches pixels inches this: inchesfromstickcenter = pixelsfromstickcenter/dpi.

to dpi, unity offers screen.dpi getting inconsistent results across devices. thumbstick way big, way small. instead went straight android's displaymetrics, xdpi, ydpi, , densitydpi. question difference between declared size in inches , size obtained using displaymetrics see densitydpi rounded value, , should using xdpi or ydpi.

i tested things trying compute width of screen in inches (my landscape, these examples assume landscape). when divide screen pixel width (1280) xdpi (195.4) on 1st gen n7, overestimates screen width half inch (6.55 inches, compared under 6 when measured rule). when divide densitydpi (213), it's better answer. wikipedia page n7 says dpi 215, give great answer.

when test on galaxy s2, xdpi (217) gives screen size estimate, , densitydpi (240) gives underestimate third of inch.

so can't depend on either of these numbers! why neither n7 stat nothing wikipedia page? silly way of trying convert pixels real-world inches? should doing instead?

cheers!


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -