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
1
Question by cstabile18 · Mar 22, 2014 at 04:52 PM · meshmaterialcolormeshrenderer

Why isn't the color changing?

I made a very simple clock on Unity for practice, but for some reason the color of the hands won't change. I'm pretty sure I scripted it right and when I hit play the mesh render shows the correct color for the hands but that color isn't actually displayed. They seem to just stay a grey color. Here's my script and a screen shot of my Unity window. Thanks.

alt text

 using UnityEngine;
 using System;
 
 public class ClockAnimator : MonoBehaviour {
 
     private const float
         hoursToDegrees = 360f / 12f,
         minutesToDegrees = 360f / 60f,
         secondsToDegrees = 360f / 60f;
     
     public Transform hours, minutes, seconds;
 
     public bool analog;
 
 
     void Start () {
 
         GameObject ClockBack = GameObject.FindGameObjectWithTag ("Back");
         ClockBack.renderer.material.color = Color.black;
 
         GameObject [] HandsArray = GameObject.FindGameObjectsWithTag ("Hand");
         foreach (GameObject hand in HandsArray) {
 
             hand.renderer.material.color = Color.yellow;
 
         }
 
 
     }
 
     void Update () {
 
         if (analog) {
         
             TimeSpan timespan = DateTime.Now.TimeOfDay;
             hours.localRotation = Quaternion.Euler (0f, 0f, (float) timespan.TotalHours * -hoursToDegrees);
             minutes.localRotation = Quaternion.Euler (0f, 0f, (float) timespan.TotalMinutes * -minutesToDegrees);
             seconds.localRotation = Quaternion.Euler (0f, 0f, (float) timespan.TotalSeconds * -secondsToDegrees);
 
         }
 
         else {
 
             DateTime time = DateTime.Now;
             
             hours.localRotation = Quaternion.Euler (0f, 0f, time.Hour * -hoursToDegrees);
             minutes.localRotation = Quaternion.Euler (0f, 0f, time.Minute * -minutesToDegrees);
             seconds.localRotation = Quaternion.Euler (0f, 0f, time.Second * -secondsToDegrees);
 
         }
 
     }
 
 }
screen shot 2014-03-22 at 12.20.58 pm.png (144.8 kB)
Comment
Add comment · Show 7
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 getyour411 · Mar 22, 2014 at 04:53 PM 0
Share

Can you confirm your tag is Hand (not hand, Hands, etc)?

avatar image cstabile18 · Mar 22, 2014 at 05:06 PM 0
Share

I just double checked, the tag is indeed Hand.

avatar image getyour411 · Mar 22, 2014 at 05:09 PM 0
Share

Add a light to the scene?

avatar image robertbu · Mar 22, 2014 at 05:10 PM 0
Share

How the color is handled totally is dependent on the shader. If the shader does not have a main color property, then the color won't change. Go to the material you are using for the hands. If you cannot change the color in the material, you won't be able to change it at runtime. Only a fraction of the standard shaders have a main color that can change.

avatar image getyour411 · Mar 22, 2014 at 05:15 PM 0
Share

Default Diffuse appears to be one that has a main color

Show more comments

1 Reply

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

Answer by SkaredCreations · Mar 22, 2014 at 07:28 PM

You are using a Diffuse shader, which requires a light to display correctly the colors, so just add a directional light rotated to be perpendicular to your clock.

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

22 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

Related Questions

Changing two different objects renderer colour 1 Answer

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

Get average color of the texture assigned to a mesh triangle 2 Answers

Material Instance Created in Car Model Prefab 0 Answers

Saving colors of multiple mesheseach having multiple materals 0 Answers


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