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
0
Question by kliment5 · Aug 17, 2017 at 03:03 PM · colorrenderermaterial colormix

Why colors are being mixed after I try to change them?

Hi guys, I am currently working on a project where I need to implement the k-means algorithm. First of all I create different game objects in space according to their positions, and then I generate 3 spheres randomly (red, green and blue). After calculating the distance from each data point to each of the spheres, if the data point is closest to the green sphere, then I change the color of the data point to green.

But, in my case, somehow for some reason, some of the data points are not becoming green, but they mix with the color from before and I get darker green. I have tried to change the color using both this code:

 child.gameObject.GetComponent<Renderer>().material.color = Color.green;

and then I tried with:

 child.gameObject.GetComponent<Renderer>().material.SetColor("_Color", Color.green);

but in both cases for some reason the colors mix, instead of setting it to strong green.

You can see that in the images below.

This is the normal green in the inspector

alt text

and this is the darker green in the inspector.

alt text

As you can see, both material colors are the same, but the second one is darker..

The previous colors of the game objects were purple and greenish.

Thank you in advance!

normal-green.jpg (159.6 kB)
different-green.jpg (152.2 kB)
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 hexagonius · Aug 17, 2017 at 04:54 PM 0
Share

you covered the inspector with the $$anonymous$$aterial selector, so we can't see

avatar image GameDevBryant · Aug 17, 2017 at 05:21 PM 0
Share

Double check to make sure the $$anonymous$$aterial property in the inspector is showing the correct color. If the color on the $$anonymous$$aterial is correct, then it's probably a lighting issue. That would be my guess :)

1 Reply

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

Answer by kliment5 · Aug 18, 2017 at 11:02 AM

Ok, so after many trials I have decided to create my own "Red", "Green", and "Blue" materials, just normal materials with that color. And then in the code instead of changing the color of the previous material, I just assign the proper colored material, something like this :)

 // in the inspector with drag and drop I put the previously created red
 // material
 
     public Material redMat;
     
     
     child.gameObject.GetComponent<Renderer>().material = redMat;

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

69 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 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 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 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

Changing two different objects renderer colour 1 Answer

Adjust tint color of particles/additive? 2 Answers

Material color won't update! 2 Answers

Emissive Material control via script (code) 1 Answer

Changing Material Color Via Script 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