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 /
This question was closed Jul 29, 2015 at 05:52 PM by getyour411 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Tekar111 · Jun 02, 2013 at 02:41 AM · c#colorlightlerpblending

How can I change the color of a light over time?

If I have two defined colors (public Color earlyMorning = new Color (95f, 59f, 168f, 1f);) ect. How can I change the color of a light over, say, 60 seconds?

I tried light.color += earlyMorning / 60 * Time.deltaTime; however, if I log the color of the light to the console every frame, it only increases the alpha value.

So, what is the most effective method to change the color of the light over time?

Comment
Comments Locked
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

3 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by robertbu · Jun 02, 2013 at 04:06 AM

If you Google "Unity3d change color over time", you will find many hits, many with scripts. Here is one:

http://answers.unity3d.com/questions/325568/problem-with-fading-a-colour-over-time.html

Comment
Comments Locked · 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
-1

Answer by crummyrex · Jun 02, 2013 at 03:59 AM

Just attach this to the camera and set its clear flags to solid color!

 var color1 : Color = Color.red;
 var color2 : Color = Color.blue;
 var duration = 3.0;
 
 // Set clear flags to color
 camera.clearFlags = CameraClearFlags.SolidColor;
 
 function Update () {
     var t : float = Mathf.PingPong (Time.time, duration) / duration;
     camera.backgroundColor = Color.Lerp (color1, color2, t);
 }
Comment
Comments Locked · 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 robertbu · Jun 02, 2013 at 04:03 AM 0
Share

@crummyrex. This is not going to work. You are not executing anything in a loop.

avatar image
0

Answer by PAEvenson · Jun 02, 2013 at 03:09 AM

I would look up color lerping....

http://docs.unity3d.com/Documentation/ScriptReference/Color.Lerp.html

if you need more help understanding the lerp function let me know.

Comment
Comments Locked · Show 2 · 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 Tekar111 · Jun 02, 2013 at 03:28 AM 0
Share

I've never really used any lerp function before, could you give me the rundown?

avatar image PAEvenson · Jun 03, 2013 at 02:09 AM 0
Share

The link in @robertbu's comment should give you a pretty good idea...I also believe the rgba parameters of the color constructor are between 0 - 1. This might be what is throwing you off. Good luck!

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

Change light color smoothly without Lerp ??? 2 Answers

Distribute terrain in zones 3 Answers

Time.deltaTime making color lerp appear fast, but won't reach 1 1 Answer

Lerping 10 collors not that smooth 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