Hi!
I'm developing a solitaire card game using UIGrids and Smooth Tween to change the cards from one UIGrid to another.
Sometimes, when I do the reparenting, some Cards have their Spring Position active for ever, with the position changing constantly but with very very small values (visually imperceptible)...
I've put a Log to track it down and found that it was not getting in to the "enabled = false;" line... (ex. 2.328306E-15 >= 1.392746E-10 == false):
// line 96 of SpringPosition Class
if (mThreshold == 0f) mThreshold = (target - mTrans.localPosition).sqrMagnitude * 0.00001f;
mTrans.localPosition = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, delta);
if (mThreshold >= (target - mTrans.localPosition).sqrMagnitude)
{
mTrans.localPosition = target;
NotifyListeners();
enabled = false;
}
To solve it I'm checking if the local positions are different before applying the Spring Position in the UIGrid Class (If the positions are the same, there's no need to animate them)
> "&& Vector3.SqrMagnitude(t.localPosition - pos) >= 0.0001f"
// Line 369 of UIGrid.cs
if (animateSmoothly && Application.isPlaying && Vector3.SqrMagnitude(t.localPosition - pos) >= 0.0001f)
{
SpringPosition sp = SpringPosition.Begin(t.gameObject, pos, 15f);
sp.updateScrollView = true;
sp.ignoreTimeScale = true;
}
else t.localPosition = pos;
Solved my problem.. Any chance to have this (or something like that) in the next update?
Thanks