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 nowhereman · Oct 29, 2010 at 04:13 AM · lightingambient

Change ambient lighting over time?

Okay, so I'm trying to get the ambient lighting to switch to black (so everything is pitch black) and then fade up to a grayish ambient lighting. I'm not too experienced with programming, so this has been really difficult so far, and I'm left with a headache and little progress. I've been trying to use lerping

var duration : float = 1.0; var color0 : Color = Color.black; var color1 : Color = Color.grey;

function Update () { Debug.Log(RenderSettings.ambientLight); var t : float = Mathf.PingPong(Time.time, duration) / duration; RenderSettings.ambientLight = Color.Lerp (color0, color1, t);} }

But then it keeps lerping between the two colors, and I only want to go through the cycle once. Anyone know anything that would work?

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
5
Best Answer

Answer by Borgo · Jan 26, 2011 at 12:53 PM

Ok my friend, here is a code that I created for you...
You can set any numbers of colors you want and call SetChangeTime to change the time that the colors will lerps.
In your code, you used the old color to lerps, but you need to use the current color.

private var currentColor : int = 0; var changeTime : float; var colors : Color[];

function Update () { RenderSettings.ambientLight = Color.Lerp (RenderSettings.ambientLight, colors[currentColor], changeTime*Time.deltaTime);

 //this is just to test
 if(Input.GetKeyDown("space")){
     NextColor();
 }

}

function NextColor(){ if(currentColor>=colors.length-1){ currentColor = 0; }else{ currentColor +=1; } }

function SetChangeTime(ct : float){ changeTime = ct; }

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
avatar image
0
Best Answer

Answer by nowhereman · Nov 22, 2010 at 03:15 PM

I guess to answer my own question, I found out the best way to do this was make a GUI Texture that was completely black and covered the entire screen, then change the alpha value in a for loop to make it look like it was fading in and out. It's a little crude, but it works really well

Comment
Add comment · 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 Borgo · Jan 26, 2011 at 12:32 PM 0
Share

But this have a problem that if you want to ilu$$anonymous$$ate a certain place will not works.

avatar image burtonposey · Apr 10, 2012 at 04:11 AM 0
Share

You're also going to have fillrate problems if you have any mobile applications. You want to avoid geometry of any kind (planes included) that fill up a lot of the screen in a semi-transparent fashion.

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

No one has followed this question yet.

Related Questions

How do I make mobile-game-style ambient fog? 2 Answers

Need help with 24 Hour timing script. 1 Answer

RenderSettings.ambientProbe "empty", how to access? 0 Answers

[SOLVED] In which GI lighting modes are different light probes/maps used? 1 Answer

Toggling Ambient Light intensity 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