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 lampshade · Apr 27, 2011 at 05:28 AM · particlescolor

Changing color of particles

The particles that I wish to change color are attached to a game object and have all the other necessary components such as the animator and renderer. Here is how I am coding it:

void ChangeColor() { if (GetComponent<ParticleAnimator>().colorAnimation[0] == new Color(255,255,255,10)) { Debug.Log("ChangeColor");

     ParticleAnimator pAnimator = GetComponent&lt;ParticleAnimator&gt;();
     Color[ ] modifedColors = pAnimator.colorAnimation;

         for (int i = 0; i &lt; modifedColors.Length; i++)
         {
             modifedColors[i] = Color.red;
         }
 }
 else
 {
     Debug.Log("Already Changed");
 }

}

Apparently, the condition comparing the first element of the colorAnimation of the ParticleAnimator component is not white, when i know that it is..What could be the problem?

I also tried GetComponent().colorAnimation[0].Equals(Color.white); and that did not help either.

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 DaveA · Apr 27, 2011 at 05:48 AM 0
Share

Where are you assigning the modifiedColors back to the pAnimator?

avatar image lampshade · Apr 27, 2011 at 09:41 AM 0
Share

right, i rushed through that, thanks DaveA, your suggestion was/is the answer.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Apr 27, 2011 at 05:52 AM

Are you sure it's white? Color.white is Color(1.0, 1.0, 1.0, 1.0) and you could be using Color(1.0, 1.0, 1.0, 0.0) or something.

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 Eric5h5 · Apr 27, 2011 at 07:21 AM 0
Share

@lampshade: colors in Unity are normalized in the 0.0 to 1.0 range. See the docs; the color values you're using in your code won't work at all. http://unity3d.com/support/documentation/ScriptReference/Color.html Assu$$anonymous$$g 8 bits per gun, 0.0 = 0, and 1.0 = 255. What you're using is Color(1.0, 1.0, 1.0, .0392) approximately, which is not Color.white.

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

Trying to change the alpha on a particle system. 1 Answer

Changing Color of Particles in Javascript 1 Answer

Using Colour over Lifetime with particles that have a Texture Sheet Animation 0 Answers

Can't make black/grey smoke? - Particle Systems 0 Answers

Accessing material of particle renderer?? 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