Author Topic: Unified Anchor tween postion issue:the widget will reset to old after tween  (Read 2889 times)

liuyi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Hey ,guys

I am confused with Unified Anchors serval days already.
There is a gameobject, it's a panel. And I want move it from left to right(like ios slide effect);
The gameobject  attached UIWidget with Unified anchors.

The problem is that the position of the panel(gameobject) will reset to the old postion(0,0,0) after the tween completed;

So I have a idea to fix it. after tween set widget's anchors to None;
But is this the correct way?

My code like below:

Hashtable compelteParams = new Hashtable();
compelteParams.Add("currentPage",currentPage);
compelteParams.Add("nextPage", nextPage);

 iTween.MoveTo(currentPage.gameObject, iTween.Hash("x", Screen.width, "time", 0.6, "islocal", true, "oncomplete", "onSwitchComplte", "onCompleteTarget", gameObject, "oncompleteparams", compelteParams));

 public void onSwitchComplte(Hashtable obj)
    {
        Page currentPage = obj["currentPage"] as Page;
        //Page nextPage = obj["nextPage"] as Page;
        //currentPage.gameObject.active = false;
         UIWidget widget = currentPage.GetComponent<UIWidget>();
         widget.leftAnchor.target = null;
        widget.rightAnchor.target = null;
        widget.topAnchor.target = null;
        widget.bottomAnchor.target = null;

        Debug.Log("onSwitchComplte ");
       
    }


the same result with this code:
TweenPosition tweenpos =TweenPosition.Begin(currentPage.gameObject, 0.4f, new Vector3(Screen.width, 0, 0));


NGUI version is latest:3.4.9
 
« Last Edit: February 14, 2014, 02:27:01 AM by liuyi »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
You should use NGUI's tweens, not iTween. TweenPosition adjusts the anchor so the reverting to old position doesn't happen.