Author Topic: iTween and NGUI  (Read 15594 times)

BSECaleb

  • Guest
iTween and NGUI
« on: June 08, 2012, 12:57:38 PM »
I'm having an issue with trying to animate a ngui sprite using itween. When the tween runs the sprite moves WAY more than the tween amount...

I created a simple test scene with only one sprite with one script attached. The only code in the script:

  1. void Start()
  2.     {
  3.         iTween.MoveBy(gameObject, new Vector3(-64.0f, 0, 0), 10.0f);
  4.     }
  5.  

The sprites transform is:
P X 0 Y 0 Z 0
R X 0 Y 0 Z 0
S X 48 Y 64 Z 1

When I play the scene the x position reported for the sprite gameobject is: -15249.34

If I attach the same script to a simple cube it moves as it should.

Whats going on?
« Last Edit: June 08, 2012, 12:59:26 PM by BSECaleb »

PhilipC

  • Guest
Re: iTween and NGUI
« Reply #1 on: June 08, 2012, 01:20:02 PM »
You dont want to use NGUI's built in tweening? I'm not familiar with iTween so i'm unsure what it could be doing.

BSECaleb

  • Guest
Re: iTween and NGUI
« Reply #2 on: June 08, 2012, 01:39:18 PM »
As far as I can tell nguis built in tweening doesn't have an option for relative movement, which is what iTweens moveby does. I know I could probably just get the current position, calculate the new position based on how much I want to move on each axis, and then use the built in tweening to move in an absolute way but I would rather keep it simple. I also want to understand what is going on in ngui that makes the sprites translation work. I have to confess that I'm a bit confused about how to deal with translation on a ngui widget since translation is in pixel units instead of world units.

FWIW, MoveBy defaults to translation in local space.
« Last Edit: June 08, 2012, 01:41:33 PM by BSECaleb »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iTween and NGUI
« Reply #3 on: June 08, 2012, 01:51:32 PM »
Sounds like iTween is moving it in world space (transform.position). NGUI's tweens are based in local space (transform.localPosition).

BSECaleb

  • Guest
Re: iTween and NGUI
« Reply #4 on: June 08, 2012, 02:28:29 PM »
So it looks like this may be a bug in iTween. The documentation says it defaults to local space. I even tried manually setting the space to self in the hash arguments. I think iTween is still trying to move in world space. When I use HOTween and set it to animate localPosition it works as expected.

ding

  • Guest
Re: iTween and NGUI
« Reply #5 on: June 11, 2012, 12:51:26 AM »
Hello

I didn't try MoveBy, but I'd tried MoveTo, and it works. Hope this helps.

iTween.MoveTo(gameObject,   iTween.Hash("position", new Vector3(-1000, gameObject.transform.localPosition.y, Btns.transform.localPosition.z), "time", 1, "islocal", true )));      
            
Ding

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: iTween and NGUI
« Reply #6 on: June 11, 2012, 04:29:56 AM »
Well MoveTo sounds like a direction position you specifiy and MoveBy sounds like a given distance to move.

ArenMook, you might want to put the difference between transform.position and transform.localPosition as a sticky/faq because that issue seems to be catching out a lot of people.

joreldraw

  • Guest
Re: iTween and NGUI
« Reply #7 on: June 11, 2012, 07:58:54 AM »

terencekwan

  • Guest
Re: iTween and NGUI
« Reply #8 on: October 04, 2012, 02:30:07 PM »
I have the same problem. To solve it, remember to add: "islocal", true

Stephan

  • Guest
Re: iTween and NGUI
« Reply #9 on: October 05, 2012, 10:54:00 AM »
iTween FadeTo is also not working.  It works on regular game objects using the same shader.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iTween and NGUI
« Reply #10 on: October 05, 2012, 06:09:36 PM »
Use TweenColor. iTween and NGUI are two completely different packages.

Stephan

  • Guest
Re: iTween and NGUI
« Reply #11 on: October 24, 2012, 03:18:52 PM »
Using a different tween engine for each plugin is not desirable.... especially when dedicated tween libraries have so many more features.  Is there any easy way to fade a panel + children with the built in Tween library.  From a UI perspective that is a pretty critical piece of functionality.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iTween and NGUI
« Reply #12 on: October 24, 2012, 04:38:41 PM »
iTween was not designed to work with NGUI. Built-in tweening was. NGUI doesn't expose a lot of public variables -- which is the only thing iTween can tween. NGUI exposes properties -- which built-in tweening was built to use.

chuk2bp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 13
    • View Profile
Re: iTween and NGUI
« Reply #13 on: August 21, 2013, 11:29:57 PM »
I know this topic is loooong since dead, but for those of you who still actively use iTween in their projects I figured I'd post this. its worth noting that you should be aware that when using itween for NGUI widgets, you should always take into account the UIRoot's transform scale value. This is likely why most people are experiencing such radical positioning problems (and assuming that its defaulting to world space). Hope this helps!

bxh883

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: iTween and NGUI
« Reply #14 on: September 06, 2015, 10:37:46 PM »
I know this topic is loooong since dead, but for those of you who still actively use iTween in their projects I figured I'd post this. its worth noting that you should be aware that when using itween for NGUI widgets, you should always take into account the UIRoot's transform scale value. This is likely why most people are experiencing such radical positioning problems (and assuming that its defaulting to world space). Hope this helps!

works well! Maybe a good solution!
Thank u.