How to move ui elements unity?
Okay, I won't go into details with my game, but I've made a super-simple example which represents my issue.
I have a 2D scene these components:
When the scene loads, and I tap the button this script executes:
I have also tried this code:
The problem is, that when I click the button, the x-pos of the object sets to -1536 which is not as expected. Picture shows the scene after the button has been clicked. Notice the Rect Transform values:
So I did a little Googling and found out about ScreenToWorldPoint, WorldToScreenPoint etc but no of these conversions solves my problem.
I'm pretty sure I'm missing someting here, which probably is right in front of my, but I simply can't figure out what.
I hope someone can point me in the right direction.
- public void MoveSayDialogToTop()
- {
- var sayDialog = GameObject. Find("SayDialog"). transform. Find("Panel"). GetComponent
(); - var pos = sayDialog. localPosition;
- sayDialog. localPosition = new Vector3(pos. x, 840, pos. z);
- }
Related Questions
- How to get full screen on zoom?
- How to check hdfc debit card emi limit?
- How to open hsn code in tally?
- How to install jboss in centos 8?
- How to check empty array in ngif?
- How to call id in html?
- How to achieve success in life speech?
- How to block someone who texts you?
- How to animate puzzle pieces in powerpoint?
- How to prepare isolyte p?