Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Malcolm · Aug 24, 2011 at 07:14 PM · c#animationitween

Using iTween for custom variables

I am looking for a way to use iTween to ease the values of some custom variables on one of my scripts. It looks like ValueTo() is similar to what I would want, but I cannot figure out how to pass in a reference to the script as it is not a GameObject.

Example:

 public class SampleClass : MonoBehaviour {
     public float sampleValue = 0.0f;
 }

SampleClass would be attached to a game object. I would like to ease sampleValue.

Comment
Add comment
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

3 Replies

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

Answer by Nerull22 · Aug 31, 2011 at 01:01 AM

In cases like this, you can use something like this:

iTween.ValueTo(gameObject, iTween.Hash(.....));

Specifically type in "gameObject". See if that works for you.

Comment
Add comment · 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
5

Answer by Malcolm · Aug 31, 2011 at 01:26 AM

That works perfectly thank you.
Code snippet in case anyone else needs a reference of how to use:

 public class TweenTest:MonoBehaviour {
       public float someValue = 0.0f;
     
       public void Start () {
             Hashtable param = new Hashtable();
             param.Add("from", 0.0f);
             param.Add("to", 10.0f);
             param.Add("time", 10.0f);
             param.Add("onupdate", "TweenedSomeValue");
             iTween.ValueTo(gameObject, param);
       }
 
       public void TweenedSomeValue(float val){
             someValue = val;
       }
 }

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 philjhale · May 12, 2013 at 09:47 AM 0
Share

That's useful thanks. You can also use the iTween.Hash() method to avoid instantiating a HashTable.

avatar image
0

Answer by TimK.Disney · Apr 17, 2013 at 01:07 AM

Word to the wise: Do not use "TweenUpdate" as your callback function name. That is a function in the iTween library that is in the call stack leading to the value tween update call. Doing this will cause your tween to recurse infinitely, will cause Unity to blow its stack and hang (boo, Unity! Ought to nuke any scripts in which stack depth exceeds a certain value!) and will leave you scratching your head going "wtf"?

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

C# Make Child Not Animate Looped Animation 1 Answer

How to reduce Animation duration dynamically in c# script 1 Answer

How to add some animation? 1 Answer

iTween Rotation not exact 0 Answers

How would I go about carrying out another object's animation IN C#! 1 Answer


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