Quantcast
Channel: Questions in topic: "screen size"
Viewing all articles
Browse latest Browse all 225

Vector move based on screen size

$
0
0
Hi! I have just started making a mobile game with Unity. This is my first foray into unity, so I'm very much learning as I go. Reckon I'll be here a lot. Anyway, with one of my UI elements, "Clipboard", the idea is that when you click on it, the object moves down to reveal more of the information on it. At the moment I've done this using the code ClipNudge = 80; if (ClipDown == false) { ClipDown = true; Clipboard.transform.Translate(Vector3.down * ClipNudge * Time.deltaTime); } else { ClipDown = false; Clipboard.transform.Translate(Vector3.up * ClipNudge * Time.deltaTime); } Now, when I do this in Unity, and try moving through all the resolutions, it scales properly and looks fine on all displays. Everything else does too, because I've set up my anchors and Canvas scalers, etc. However, when I build out the apk and run it on my phone, the jump is too large and the clipboard goes very nearly off the bottom of the screen. So, my question is, how do I use code to move this object (and then back again), but do so in a way that scales to the screen size I'm using?

Viewing all articles
Browse latest Browse all 225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>