playMaker

Author Topic: Set Position of UI Object with Actions [SOLVED]  (Read 4929 times)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Set Position of UI Object with Actions [SOLVED]
« on: February 21, 2017, 04:25:54 PM »
Hello there!

I've had this problem before and found funny ways of working around it but it involves a lot of guesswork and I would like to understand what is actually going on.

Sometimes I would like to move UI objects with I Tween actions but if I set the vector position inside the action as what I see as the objects position in the inspector, it always goes someplace unexpected when I'm playing the game.

For example, if I wanted to move a RawImage from where it sits at x0,y0,z0 to x0,y5,z0, I would try to use I Tween Move To and set the vector position to x0,y5,z0. However when I do that, it doesn't move to that position but instead to what I assume is that position in screen space?

By guessing and checking different values, it is possible to get the object to around where I need it but I'm not sure how I could come up with the proper number without guessing to be sure it is exactly where I want it.

Could someone please explain what is actually going on here and if there is an easy way to set the position of UI objects more accurately?

Any advice would be appreciated!
« Last Edit: February 22, 2017, 08:12:39 AM by acornbringer »

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Set Position of UI Object with Actions
« Reply #1 on: February 21, 2017, 05:42:06 PM »
If it's a child of an object, and you want to move that object it's a transform.localPosition rather than transform.position (parent objects) but if it's a parent object you are moving, are you using anchors or not? If you are using anchors you need to look at RectTransform.anchoredPosition etc...

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Re: Set Position of UI Object with Actions
« Reply #2 on: February 21, 2017, 07:13:24 PM »
They are, indeed, children of a panel. Their anchor is set to top center of the canvas so when I set their position to x0,y0,z0, they will all center to that anchor. However, if I set the position to that value with I Tween Move To, it will go to the bottom left corner of the screen and when I change the action to use local space instead, it will go to the center of the panel but not the anchor's center.

Is there an action that uses "RectTransform.anchoredPosition" instead? Also, is there a way to expose those values? Because I'm trying to move the object to a specific point on the canvas, I would need to be able to see it somehow in the inspector right? Otherwise, all I see are the normal game object transformation values.

Thanks :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Position of UI Object with Actions
« Reply #3 on: February 22, 2017, 01:38:19 AM »
Hi,

 Yes, there is an action RectTransformSetAnchoredPosition for this.
 
This is what I am using for my soon to be available IOS cell behavior

 Bye,

 Jean

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Set Position of UI Object with Actions
« Reply #4 on: February 22, 2017, 07:50:05 AM »
As Jean mentioned, there is an action.

Quote
Also, is there a way to expose those values?

Top right corner of your Component list, there is a little "hamburger" menu, click on it and select from "Normal" to "Debug". That should show you more info.

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Re: Set Position of UI Object with Actions
« Reply #5 on: February 22, 2017, 08:11:52 AM »
Excellent! That worked perfectly :) Thank you both! I might as well just leave the inspector in debug so I have access to all of that stuff.

That iOS Cell Behavior looks great too, jeanfabre!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Position of UI Object with Actions [SOLVED]
« Reply #6 on: February 23, 2017, 02:05:01 AM »
Hi,

 yeah :) the IOS cell behavior is bringing a lot of improvement for the uGui proxy as well for complex events within scrolling lists, quite a complex beast to tackle but it's getting there.

Bye,

 Jean

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Re: Set Position of UI Object with Actions [SOLVED]
« Reply #7 on: February 23, 2017, 07:26:19 AM »
It sounds really great, jean! That intuitive, tactile UI design is definitely appealing :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Position of UI Object with Actions [SOLVED]
« Reply #8 on: February 23, 2017, 07:30:52 AM »
Hi,

 the proxy will not be a turn key solution for this kind of cell behavior, there is still a substantial amount of work to do, but right now with the current version on the Ecosystem, you can not have multiple interactable elements combines, like a scrolllist of items that inside have more dragging and clicking involved. that's the bottom line of the demo to demonstrate the improved underlying management of the uGui proxies for event forwarding

 bye,

 Jean