Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Ashutosh8126 · Oct 02, 2013 at 06:42 PM · ngui

NGUI TweenPostion..

Hi I am new to NGUI.. I just watn to tween a gameobject from 1 position to another. I know I can do using TweenPosition script and filling in the values.. I know I can do using TweeenPosition.Begin method.. But I donn't know how to use TweenPosition class all features through scripting like onFinished delegate and Tweeinng style.. If someone can plz show me an example..

I am doing something like this..

         TweenPosition obj = new TweenPosition();
         obj.from = new Vector3(5.960464e-08f, 260, 0);
         obj.to = new Vector3(5.960464e-08f, 105, 0);
         obj.style = UITweener.Style.Once;
         obj.steeperCurves = true;
         obj.method = UITweener.Method.EaseIn;

but I can't find how to play the tween and set the onFinished delegate..

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sethuraj · Oct 02, 2013 at 07:25 PM 0
Share

Why NGUI for this simple thing..?Vector3.Lerp() will do right..?

avatar image Ashutosh8126 · Oct 03, 2013 at 11:17 AM 0
Share

Vertor3.Lerp doesn't contains Lerp Finished event..dats y..

avatar image sethuraj · Oct 03, 2013 at 04:17 PM 1
Share

You can use the TimeValue in lerp to check for lerp completion. Vector3.Lerp(from,to,TimeValue); if(TimeValue>=1) { //Do here for lerp completion. }

Hope this helps...... :-)

avatar image Ashutosh8126 · Oct 04, 2013 at 07:40 AM 0
Share

Thanks...

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by vexe · Oct 02, 2013 at 10:00 PM

I don't know why you would want to create a TweenPosition object, but anyway... First things first, here's how you normally use TweenPosition (which is something you said you know, but just to keep everything in one place):

To tween a gameObject go, from its current position to position pos during t:

 TweenPosition.Begin(go, t, pos);

Now, immediately using this notation, you could subscribe to the onFinished event by:

 TweenPosition.Begin(go, t, pos).onFinished += OnAnimFinishedHandler; // this is ok because Begin here returns a TweenPosition object, from which you could access onFinished 

 public void OnAnimFinishedHandler(UITweener tweener) // your handler must have this signature (a UITweener param)
 {
     // do whatever you want
 }

If you want to do everything manually, just create a TP object, set its from and to, the style, method, etc. When you're done, call Play to start the tweening process. You could at anytime Reset it, or Toggle it.

 var tp = new TweenPosition();
 tp.from = transform.position;
 tp.to = someOtherVector;
 tp.style = UITweener.Style.Once;        // there's also PingPong (back and forth) and Loop (when reaches end, goes back to start)
 tp.method = UITweener.Method.EaseIn;    // there's also BounceIn, BounceOut, EaseOut, etc
 tp.onFinished += myHandler;
 tp.duration = t;
 tp.Start();                             // at anytime you could reset it, using tp.Reset() getting it back to the beginning; or toggle it tp.Toggle(); reversing it

That's pretty much it.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashutosh8126 · Oct 03, 2013 at 11:16 AM 0
Share

Cool... Thanks..

avatar image
0

Answer by vanshika · Dec 17, 2013 at 02:16 PM

Hi I want to do the same, But not able to crack it. I want to use TweenPosition.Begin but just add on feature to method.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashutosh8126 · Jan 06, 2014 at 11:21 AM 0
Share

vch add on feature?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Material doesn't have a color property '_Color' 4 Answers

Setting Scroll View Width GUILayout 1 Answer

NGUI : UIPanel can't show 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges