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 Negagames · Aug 09, 2013 at 04:56 AM · c#colorcompiler bug

Strange unity color bug

I just got a hold of the free version of the A* pathfinding project, and unity is giving me 9 errors saying that the Color constructor doesn't take 4 arguments. Has something changed recently, last I checked color took arguments for red, green, blue, and alpha.

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 Jamora · Aug 09, 2013 at 08:32 AM

You left out a crucial piece of information: the type are the arguments you are trying to provide. Had you posted the error message in its entirety I would have been sure...

I'm going to take a stab in the dark here: You're trying to provide ints or doubles to the Color constructor, while it only accepts floats. Remember that floats take the f at the end (1f, 0.5f) in C#.

The components of Color need to be in the inclusive range [0,1].

Comment
Add comment · Show 6 · 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 Negagames · Aug 09, 2013 at 12:05 PM 0
Share

Nope, _$$anonymous$$eshColor = new Color (0.125F, 0.686F, 0.0F, 0.19F); And I still get errors from it

avatar image Negagames · Aug 09, 2013 at 12:18 PM 0
Share

Also Unity fails to register individual colors. For example _$$anonymous$$eshColor.r returns an error as does Color.white.

avatar image Negagames · Aug 09, 2013 at 02:20 PM 0
Share

Ok it seems to clear up when I use UnityEngine.Color, I think it's a conflict between the base definition of c#'s library and the unity library.

avatar image clunk47 · Aug 09, 2013 at 02:49 PM 0
Share

Are you putting this at the top of your code?

using UnityEngine;

avatar image Negagames · Aug 12, 2013 at 04:05 AM 0
Share

Yeah im using the UnityEngine import

Show more comments
avatar image
0

Answer by melkior · Feb 15, 2015 at 07:02 PM

I just wanted to post that the using UnityEngine.Color is what works for me as well; I do think there's some namespace conflict between unity and mono as of the updates that came recently

Example: private static UnityEngine.Color white = new UnityEngine.Color(1, 1, 1, 1);

Works fine.

NON-Working example that used to work:

private static Color = Color.white;

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

17 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Changing 3DText color through C# script (non-GUI) 1 Answer

Change Particle StartColor 'Random Between Two Colors' 1 Answer

Blend into next color instead of jumping to next 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