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 Sourabh Kondapaka · Sep 20, 2014 at 07:19 PM · lerp

Color' does not contain a definition for 'red'

I'm trying to grab the color of a cube and change it over time using the lerp function But it says the color does not contain the definition for red and even for green.

 public Color inicolor;
 public Color redColor = Color.white;
 public Color blackColor = Color.black;
 void Awake()
 {
     inicolor = gameObject.GetComponent<Color>();
 }


 void Update () 
 {
 colorchanged ();    
 }


 void colorchanged()
 {

 if (Input.GetKey (KeyCode.A)

     inicolor = redColor;

 else
 inicolor = blackColor;


renderer.material.color = Color.Lerp(renderer.material.color,inicolor, Time.deltaTime * 5);

 }


Comment
Add comment · Show 1
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 robertbu · Sep 20, 2014 at 07:29 PM 0
Share

When you get the kind of error you describe, it is usually because you name one of your classes the same as a Unity class. So if the fixed that @tanoshimi indicates don't fix the problem, look for a class you created named 'Color' in your project, and change the name.

1 Reply

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

Answer by tanoshimi · Sep 20, 2014 at 07:24 PM

Does that script really generate that error? I don't see you attempting to use Color.red anywhere. However, I do see other problems:

  • You're missing a ) on line 19.

  • You're trying to assign an object to a Color variable on line 6. Assuming the "Color" is the name of a script attached to the gameobject, and it has a public color variable called "color", then you want inicolor = gameObject.GetComponent().color; (however, it would be better to avoid using "color" as your class or variable names anyway)

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 Sourabh Kondapaka · Sep 20, 2014 at 07:56 PM 0
Share

@tanoshimi thanks a lot man it was the name of the script and also the braces...I'm a real beginner you know..

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

2 People are following this question.

avatar image avatar image

Related Questions

Not Sure How to Get Around this Problem 1 Answer

changes to colour alpha affect RGB values, but not in the same way 1 Answer

Smoothing end of a lerp 2 Answers

Lerp color of verts with position bigger than 1 1 Answer

Lerping doesn't return to the same position? 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