News: Enjoy our Christmas offer 30% off on our latest package Tower Defense Level Kit http://u3d.as/m7h

  • September 24, 2018, 03:11:08 PM

Login with username, password and session length

Author Topic: Problem with moving from Bottom and Pivot Y set to 0 and anchorMin y is 0  (Read 1193 times)

Offline xyzDave

  • Newbie
  • *
  • Posts: 9
Hi,
just tried to move an image up from the bottom, with it's pivot Y value set to 0 (so it perfectly aligns with the bottom of the screen when scaled), and anchorMin y is 0

Unfortunately the image doesn't move in, instead it just appears.

This seems to be due to a possible problem in ComputePosition.

For EMMotionProperties.MotionDirection.Bottom it just takes

Code: [Select]
position.y = originOffset.y -  pivotOffset.y;

As
Code: [Select]
pivotOffset = new Vector2(cachedTransform.sizeDelta.x * cachedTransform.pivot.x * scale.x, cachedTransform.sizeDelta.y * cachedTransform.pivot.y * scale.y);

when  cachedTransform.pivot.y is zero, pivotOffset.y becomes zero, and thus position (the returned value) is originOffset.y (which is anchorMin.y)

This too is zero, so position is zero.

As the passed in anchoredPosition is zero, the returned position is position is the same so it doesn't move.

Any ideas?

Thanks

Dave

Offline xyzDave

  • Newbie
  • *
  • Posts: 9
Re: Problem with moving from Bottom and Pivot Y set to 0 and anchorMin y is 0
« Reply #1 on: December 10, 2015, 05:47:38 PM »
After a quick play around, should

ComputePosition be modified to read

case EMMotionProperties.MotionDirection.Bottom:
            if (!inside)
                    position.y = originOffset.y - GetScalerResolution().y + pivotOffset.y;
            else

Not sure if the pivotOffset should be a + or -?

Seems to bring my box on (i.e. works for me)
Not tested in any other cases.

Let me know.
Thanks
Dave

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: Problem with moving from Bottom and Pivot Y set to 0 and anchorMin y is 0
« Reply #2 on: December 10, 2015, 06:35:24 PM »
Hi,

In such cases, I recommend using the "user defined" mode, which allows to force the start  position without calculation.

Thank you for the workaround, I will test it in different case.The new UI allows so much freedom, it becomes very hard to foresee everything

Nicolas

Offline xyzDave

  • Newbie
  • *
  • Posts: 9
Re: Problem with moving from Bottom and Pivot Y set to 0 and anchorMin y is 0
« Reply #3 on: December 10, 2015, 10:05:11 PM »
Hi Nicholas,
thanks for getting back to me.

I was trying to avoid the "user defined" mode as, as far as I can tell, the coordinates are not scaled, so the results will differ between iPad and iPhone - i.e. if the screen resolution changes, it may not work, and the panel may be on screen.  Or have I misunderstood the code?

Let me know how you get on with your tests over the workaround.

Totally understand you being able to miss things - it's impossible to test for everything.

If you have trouble testing, let me know and I'll create some test cases, check the results are correct and report back.
The really great thing about this plugin is you have supplied the source code, so totally happy to help get all issues resolved as I plan to use this for a couple of projects at least.

Cheers,
Dave