# Android Touch Variation Correction? (How to use Screen.dpi?)

 0 This has been some confusion as to what I am asking on both sides (As I wasn't clear or completely sure myself). I'm having a problem formulating the word problem (Not solving it) of how this:can help me normalize this:So that I can have a one, scaling solution across multiple resolutions (and platforms) like these:For instance, I suppose I could use PPI (Pixels Per Inch often known as Dots per inch - DPI) to calculate the physical size of the screen and download an appropriate resolution set of UI(assume we have a server with many resolution sets of User Interface available for download) specific to that size (Again, how does PPI even relate the resolution to physical screen size?)This current problem is where does PPI (Screen.dpi) fit into calculating a normalized swipe delta change across multiple size screens?Please let me know if I can be any more clear, because "divide/multiply as necessarily" is not helping me determine the relationship between PPI and normalizing swipe distance.Note: these images were pulled from random google searches of: pixels per inch swipe android screen sizesOriginal:So building off of my first question, Delta Position is different for every Android phone type. Is there a good way to go about correcting it between phones with an algorithm? Our director doesn't want to put something inside the game to change the sensitivity because most of our target audience (teachers) wouldn't even bother this.Edit:Ok, so I guess its time to revamp the question. Jessy pointed out that Screen.dpi would help with the correction, but how would .dpi be used in an algorithm to scale uniformly across multiple dpi's? I don't even know where to begin with constructing a formula to achieve this. Here is the quick code I threw together to get an effect: ``````Vector2 = Input.touches[0].deltaPosition; float speed = ms.y / Screen.dpi * 10; ``````Why am I dividing the vertical delta position? I have no idea. So what would be a correct way to use Screen.dpi so that it would scale across android devices(and ideally to ios devices as well)? one_finger_swipe.png (2.7 kB) ppi.png (11.0 kB) more ▼ asked Jan 23 '12 at 01:55 PM SirGive 1.2k ● 25 ● 32 ● 50 Any ideas? Jan 23 '12 at 03:35 PM SirGive I really wish I could get an answer for this. :/ Apr 17 '12 at 12:44 PM SirGive It would help if you answered my comment from two months ago, but I'm not sure we can help you. Are you familiar with ratios/division/multiplication? You'll need to be. Apr 17 '12 at 01:31 PM Jessy I'm not familiar with how to use Screen.dpi. What would be a practical use? It returns a float that has the number of pixels per screen (right?) So what do I do with that? Multiply it against the target screen resolution? I know that its useful, but I simply don't understand how to use that information. Apr 19 '12 at 05:34 PM SirGive Not right. Other Screen and Camera variables yield resolution information. dpi is a misnomer, but close enough - it should be ppi. That is, Pixels Per Inch. For your calculations, that mean you have (Screen.dpi pixels)/(1 inch). Multiply and divide as necessary to achieve your goals. Apr 19 '12 at 05:48 PM Jessy add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 DPI is irrelevant. The key is `Touch.deltaTime`.The `Touch.deltaPosition` is the change in position over that time, not over the time of the last frame (the Unity docs are slightly unclear on this, since the events themselves arrived during the last frame). This is why the sum of all `Touch.deltaPosition` values will not equal the difference between `Touch.position` values.You can account for this as follows: ``````t.deltaPosition * Time.deltaTime / t.deltaTime ``````So, the code for dragging a scrollview would be: ``````position = GUILayout.BeginScrollView(position); ... GUILayout.EndScrollView(); if (Event.current.type == EventType.Repaint) { var area = GUILayoutUtility.GetLastRect(); for (var i=0; i
 0 Again, how does PPI even relate the resolution to physical screen size? The second P is "per".The ratio of inches to pixels is (1 inch / Screen.dpi pixels).So, the physical width of the screen is (Screen.width pixels * (1 inch / Screen.dpi pixels)).I'll cancel out terms for the height result: (Screen.height / Screen.dpi) inches.Touch.deltaPosition is also measured in pixels.Multiply or divide as necessary to achieve the desired result. more ▼ answered Jan 23 '12 at 08:14 PM Jessy 15.7k ● 72 ● 95 ● 198 Sorry for the late reply, but there isn't a Screen.dpi? Feb 10 '12 at 02:33 PM SirGive Not in Unity 3.4 there isn't. Get the beta. Feb 10 '12 at 02:41 PM Jessy Hmm how stable is the beta? It might work in a future solution. But definitely not on the current project. Feb 10 '12 at 04:08 PM SirGive You asked on January 23rd. If you let that same time delta pass again, I bet it won't be beta anymore. It's not like you can't rebuild the project with Unity 3.5; UT works hard to ensure this causes no problems. Your project isn't tied to a Unity release. I can't imagine anything would work well on Android without knowing the dpi - too many possibilities. The beta has been as stable for me as the 3.4 cycle. Feb 10 '12 at 04:30 PM Jessy It's out. Feb 14 '12 at 08:57 PM Jessy add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: