Using same lighting in-game, as in editor (when sun button is not pressed)

You know how the sun button turns on and off the option to see how the light sources used in the scene will light the scene.

But if you turn the button off, the scene is lighted as well, and it is lighted favourably sometimes, in my taste.

How does such lighting work?

How can I have the same kind of lighting in-game, as I do have when the sun button is not pressed?

Is it something as easy as parenting a directional light to the camera? or something else?

alt text

Yeah you could definitely child a Directional light to the Main camera to get light from the camera direction. If you have Unity Pro and cast shadows from the Directional light the shadows will always turn away from the view angle (something to keep in mind). Another thing is the Unlit Shader-family where you could draw objects always lit independent of the light in your scene.

I would anyhow suggest that you work with point lights in the area you want to lit, but it depends of what you are trying to achieve of course.

Maybe controlling the Ambient Light you could achieve the desired results. You can tweak the Ambient Light color in the editor, or modify it at runtime changing the RenderSettings.ambientLight variable. If you want to modify only its intensity, you must change its componentes r, g, b, a at the same time (although a does nothing in this case). I suggest you to define the color in a variable, then multiply it by a float between 0 and 1 in order to control the ambient light, like this:

var ambLight:Color = Color.white;
var intensity:float = 0.5;
  .
  .
function Update(){
  .
  .
  RenderSettings.ambientLight = ambLight*intensity;
  .
  .

OBS: If you modify the RenderSettings.ambientLight at runtime in the Update() like above, the Render Settings Ambient Light parameter won’t respond anymore - you should modify the script variables intensity or ambLight in the Inspector instead.