Problem tweening UI panels using anchorMin and anchorMax
« on: February 02, 2016, 02:48:33 AM »
I'm attempting to move UI panels on and off of the screen (in a resolution independent way) by tweening the anchorMin and anchorMax members of the panel's RectTransform component.  Essentially, I've parked all of my panels just off the left side of the screen by setting their anchorMin and anchorMax properties to (-1, 0) and (0, 1) respectively.

When it's time to slide a panel into view, I call the below code and pass it the GameObject containing the panel.

Code: [Select]
private void ShowHudPanel(GameObject panel)
    RectTransform rect = panel.GetComponent<RectTransform>();

        .Join(DOTween.To(() => rect.anchorMin, x => rect.anchorMin = x, new Vector2(1f, 0f), 1f))
        .Join(DOTween.To(() => rect.anchorMax, x => rect.anchorMax = x, new Vector2(1f, 0f), 1f))

The result is odd.  Essentially, it seems like the tween is only playing for a single frame.  With the one second duration above, the panel is made barely visible on the left edge before the tween (apparently) finishes.  As I decrease the duration, the above makes the panel more visible (as each frame would have to move the panel further).  If I decrease the duration to something silly (like 0.01), the entire panel is made visible - but only because it needs to move the entire distance in a single frame.

I'm using "DOTween.defaultTimeScaleIndependent = true" to make the tweens Unity time independent.  Though, I even set that to false and ensured that my Unity time.timeScale was set to 1 and I get the same results.

I've also tried the above with and without the "SetRelative" (making appropriate adjustments to the end vectors), but the results are the same.  Originally, I assumed I had somehow misdefined the tweens, but I no longer think that's the case (since short duration's prove the tween works as expected).

It just seems like I'm only getting 1 frame of animation from the above for some unknown reason.  I'm using the most recent version of DOTween (1.1.135) and Unity 5.3.1f1.

I also tried initializing DOTween with "LogBehaviour.Verbose", but that doesn't indicate any problems in the log panel.

Thanks for your input.

« Last Edit: February 02, 2016, 05:38:31 PM by jgodfrey »

Re: Problem tweening UI panels using anchorMin and anchorMax
« Reply #1 on: February 02, 2016, 03:19:26 AM »
Hmmm... It seems that something was messed up with DOTween's independent timing functions.  Not sure where or why, but after some fiddling in the Utility panel, everything started working.  I still have a few issues, but it seems I'm over the "tween won't play" hurdle.