basic concept:
tween a panel BY (300,0,0). (as in, move from its CURRENT position 300 to the right).
later, tween same panel (0,50,0). As in, move from its CURRENT position 50 up).
I wrote this, and it SHOULD work, but instead of moving it from it's current position, it ONLY moves the panel from it's ORIGINAL position. So the first tween slides it right like expected, but the next one SNAPS it back to 0,0,0 and tweens it up.
static void Shift (GameObject menu, float duration, Vector3 shift)
{
Vector3 pos = menu.transform.position;//starting position
Debug.Log(string.Format("current x:{0},y:{1},z:{2}",pos.x, pos.y, pos.z));
Debug.Log(string.Format("Shift x:{0},y:{1},z:{2}",shift.x, shift.y, shift.z));
Vector3 newPos
= new Vector3
(pos
.x+shift
.x, pos
.y+shift
.y,pos
.z+shift
.z);
TweenPosition tween = TweenPosition.Begin(menu,duration,newPos);
//tween.from = pos;
}
"pos" always returns something like "current x:-0.0001144976,y:0.1177472,z:0" so I'm not sure why menu.transform.position will SHOW the right coordinates in the inspector, but the actual data as revealed by the debug log is wrong. It seems that tweenposition doesnt *actually* move the thing?
EDITSo I ended up making Shift do this, which seems really backward and obtuse, but if I dont then it won't actually tween from the current position! There has to be a better way. Note that this also only works from a 0,0,0. And since transform doesnt seem to get the actual location, I can't GET the panels location to tween from.
static void Shift (GameObject menu, float duration, Vector3 shift)
{
Vector3 pos;
try
{
pos = menu.GetComponent<TweenPosition>().to;
}
catch (Exception ex)
{
pos= Vector3.zero;
}
Debug.Log(string.Format("current x:{0},y:{1},z:{2}",pos.x, pos.y, pos.z));
Debug.Log(string.Format("Shift x:{0},y:{1},z:{2}",shift.x, shift.y, shift.z));
Vector3 newPos
= new Vector3
(pos
.x+shift
.x, pos
.y+shift
.y,pos
.z+shift
.z);
TweenPosition tween = TweenPosition.Begin(menu,duration,newPos);
tween.from = pos;
}
(also, a secondary question)Is there any example of a tween's onFinished being used? For the life of me I can't get the thing to disable the object when a tween finishes.