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
4
Question by Can-Baycay · Dec 16, 2010 at 12:16 PM · itween

Using iTween ValueTo with onupdateparams

I have hundreds of objects (not GameObjects) and I need to interpolate some values on them. Instead of making them separate GameObjects, I would definitely prefer keeping their classes as lightweight as possible.

The problem with ValueTo is, I need to send an object reference to onupdate and I totally agree that iTween should also send the interpolation value to onupdate as well :). But there is an inconsistency since iTween seems to use onupdateparams parameter internally to hold the interpolation value and overwrites what we have given when creating the tween.

I can't find any examples around that uses ValueTo with onupdateparams, even in iTween's Callbacks Example and ValueTo Example.

Comment
Add comment · Show 2
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 FlawlessDog · May 25, 2011 at 04:25 PM 0
Share

Ok, I'ma going to bump this question up, as I find meself needing the same question answered. Is there a example of this out there someplace? I purchased a couple examples from pixelplacement, but alas, there is not the example I need in there that I can find.

I can move my GUI thingy just fine, but I do need to send a var along with that onupdate...

Thanks in advance.

avatar image FlawlessDog · May 26, 2011 at 10:11 PM 1
Share

Ok. I have found a way to do what I need to do, without having to pass that extra param with the onupdateparams. So this isn't as dire a thing as it would otherwise be.

Still, I kindof would love to see this question answered if there actually is an answer...maybe Pixelplacement would like to take a crack at it? ^_~

Thanks in advance

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Wolfram · Jul 05, 2012 at 01:05 PM

With the solution prevented by karsten here, you only need to change 3 lines of code in iTween, and can then use an inline delegate for "onupdate"/"oncomplete"/"onstart" (instead of an explicit function) to execute arbitrary code with any parameters you like.

So for example you could then do something like:

         string colorToChange="_Color";
         iTween.ValueTo(gameObject, iTween.Hash(
             "from", a,
             "to", b,
             "onupdate", (Action<object>) (newVal => {
                 Debug.Log("running iTween onupdate for "+colorToChange+" "+(float)newVal);
                 renderer.material.SetColor(colorToChange,Color.white*(float)newVal);
             }
         ));
 

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 VectorSigma · Feb 18, 2015 at 01:52 AM 0
Share

Thanks for the post Wolfram Great modification.

avatar image
3

Answer by dannyskim · Dec 04, 2011 at 09:48 PM

Just like you said in your original question, the onupdateparams are handled internally by the iTween API. I have to agree with you it's a bit vague on how to utilize and set your value from the onupdate callback method, so I'll give you a straight example and hopefully you can extrapolate what you need.

 public float fromValue = 0;
 
 private IEnumerator valueToExample()
 {
      iTween.ValueTo( "from", fromValue, "to", 10, "onupdatetarget", gameObject, "onupdate", updateFromValue, "time", 5, "easetype", iTween.EaseType.easeOutExpo );
 }

 public void updateFromValue( float newValue )
 {
      fromValue = newValue;
      Debug.Log( "My Value that is tweening: " + fromValue );
 }
 }
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

iTween ValueTo onUpdateParams passing 1 Answer

iTween with multiple ValueTo calls on same GameObject 1 Answer

iTween multiple GUI elements with one callback 1 Answer

iTween ValueTo not working 1 Answer

iTween ValueTo FieldOfView isn't easing 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