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
0
Question by schwertfisch · Dec 25, 2010 at 03:21 PM · ioscoloritweenrepeating

iTween ColorTo/ColorFrom repeating between many colors in iOS

Is it possible to have the color of an object turn to green, then to the original color, then to blue then to the original color, the transition sequence being made in say 0.9 seconds and loop this whole group of transitions for a specific amount of time?

I use the following script, which is applied on the object the color of which I want to change the way I described. The color changing sequence will begin once "condition" boolean is true (condition is a static var of type boolean that's located in "OtherScript.js").

function Update () { if (OtherScript.condition){ InvokeRepeating("ChangeColors",0,1.2); } }

 function ChangeColors (){   
     iTween.ColorTo(gameObject,{"g": 2, "time": 0.3}); 
     iTween.ColorFrom(gameObject,{"g": 2, "time": 0.3, "delay":0.3}); 
     iTween.ColorTo(gameObject,{"b": 2,"time": 0.3, "delay":0.6}); 
     iTween.ColorFrom(gameObject,{"b": 2,"time": 0.3, "delay":0.9}); 

}

I test the game with Unity Remote. At the beginning "condition" is false (default value of this var) and the fps are about 170. When it becomes true (this happens by selecting some powerups that are supposed to give my object some special characteristics for a specific amount of time) the fps fall to 2 (!) which is unplayable of course.

Thanks in advance for any suggestion! :-)

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

2 Replies

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

Answer by Jessy · Dec 25, 2010 at 05:10 PM

if (OtherScript.condition) InvokeRepeating("ChangeColors",0,1.2);

Having this in an Update() function means that you will be calling ChangeColors every frame. And after that, it will continue to happen every 1.2 seconds. Obviously, that won't work, and isn't what you want. Event Handlers are the best way I know of, to take care of this, but I don't even know if they exist in UnityScript. You at least need to "undo" the condition. It isn't efficient code, if you just do that, but at least it won't yield unexpected results:

if (OtherScript.condition) {
    InvokeRepeating("ChangeColors",0,1.2);
    OtherScript.condition = false;
}
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 schwertfisch · Dec 27, 2010 at 08:48 PM 0
Share

thanks a lot Jessy. I ended up doing something else but setting the condition to false as you suggested solved the problem and it helped me better understand how function update works!

avatar image
1

Answer by pixelplacement · Dec 27, 2010 at 09:59 PM

If you look into the docs for iTween you will notice the "From" methods will cause an instantaneous change therefore the approach you are trying won't work.

I would suggest setting a variable to hold the color of the object the fire off a few delayed iTween.ColorTo methods to change it back and forth.

Good luck.

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 schwertfisch · Dec 28, 2010 at 07:50 AM 0
Share

Thanks Bob, I'll try that.

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

No one has followed this question yet.

Related Questions

Blacks are always drawn as gray on iOS (ARFoundation) 0 Answers

iOS shader with no texture, just vertex colouring and main colour 1 Answer

iOS simple shader does not work 1 Answer

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

Assigning material color with GetPixelBilinear iOS 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