• 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 Ebil · May 19, 2013 at 10:18 PM · texturematerialcolor

new Color() not working properly?

Hellooo

Didnt thought that would be a Problem, but I experienced a problem with coloring objects.

I use:

 inst.renderer.material.SetColor("_Color",BuildGreen);

To Color an Instantiated Object Green. But it shouldnt be complely green (not like a neonflash green, where you cant see the object anymore)

So I created my own Color

 Color BuildGreen = new Color(0,255,0);

I also tried

 Color BuildGreen = new Color(0,255,0,255);
 Color BuildGreen = new Color(0,255,0,0);
 Color BuildGreen = new Color(0,255,0,100);

Its always the neonflash green result, no matter what. However, if I use Color.green.... its working, the object is still visible, even if its too much green. So why isnt it working properly? What I did wrong / have to change?

Thanks in advance.

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

1 Reply

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

Answer by numberkruncher · May 19, 2013 at 10:21 PM

Each component of Color range from 0.0f to 1.0f. You can simply switch to Color32 in your case since that accepts byte components 0 to 255 instead.

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 Ebil · May 19, 2013 at 10:42 PM 0
Share

Thanks! I can use Color its ok, just didnt know it... Im so used to the byte values of Color components...

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

14 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

Related Questions

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

Changing two different objects renderer colour 1 Answer

Adding a Color Change Script to a Model 1 Answer

How to access Emission Color of a Material in Script? 5 Answers

How to change a certain colour in a texture? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges