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 Gazer · Sep 27, 2013 at 07:12 AM · colorchange

How do I change the startcolor.r in code?

Hi,

I need to have a particle system change slowly from a predetermined color ,in an array, to white. I thought the easiest way to do this might be have the startcolor r, g, b values in update like this.

this.particlesystem.startcolor.r--;

But it won't compile. Can anyone help me?

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 Fattie · Sep 27, 2013 at 01:07 PM 0
Share

is it possible you need to do this

temp = particleSystem.startColor

temp.r = .. change that or whatever

particleSystem.startColor = temp

Whereas in Javacript, you can often "just change" parts of vectors such as that

avatar image Fattie · Sep 27, 2013 at 03:53 PM 0
Share

@Gazer, hey, you need to TIC$$anonymous$$ AN ANSWER please to close the question. Pls don't forget and see you on the next question.

2 Replies

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

Answer by fffMalzbier · Sep 27, 2013 at 02:25 PM

how about this? So you can transition form one color to another.

 public Color StartColor;
 public Color Endcolor;
 Color particelcColor;
 float progress =0;

 void Update() {
      progress += Time.deltaTime * 0.5f; //speed modifier     
      particelcColor= Color.Lerp(StartColor,Endcolor,progress); //lerp the colors        
      particleSystem.startColor = particelcColor; //assign them
 }
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 Gazer · Sep 27, 2013 at 10:12 PM 0
Share

Thanks everyone!

avatar image
1

Answer by Artaani · Sep 27, 2013 at 10:45 AM

 particleSystem.startColor = new Color (1, 1, 1, 1);
Comment
Add comment · Show 2 · 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 Gazer · Sep 27, 2013 at 12:26 PM 0
Share

Ok, that tells me how to access the r,g,b. Thanks. But how do I change it slowly? Using Time.deltatime doesn't seem to work. Thanks again for helping me.

avatar image Loius · Sep 27, 2013 at 02:29 PM 0
Share

The maximum value of r, g, b, and a is 1.0, so you need to squish your numbers into that range.

color.r = ($$anonymous$$athf.Lerp(1.0f, 0.0f, Time.deltaTime / 10f)

would fade over ten seconds from the start of the game, while this one lets you start the fade at some other time:

 float startTime = Time.realTimeSinceStartup;
 ...
 color.r = ($$anonymous$$athf.Lerp(1.0f, 0.0f, (Time.time - startTime) / 10f)

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

19 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 avatar image avatar image

Related Questions

HSV Selector? 1 Answer

Horizontal Slider Normal-Background Change Color Independently 3 Answers

3D Text - How to change colour - Doesn't seem to work 2 Answers

How to change color as flashing or blink? 0 Answers

JS changing gui box color 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