Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Scene Reset - Messing with Lighting

Discussion in 'Scripting' started by UnityLock1, Jun 16, 2016.

  1. UnityLock1

    UnityLock1

    Joined:
    Jun 16, 2016
    Posts:
    1
    I am new to Unity and scripting but I have been making some progress in a project and have hit a snag. In the project the user should be able to rotate around an object and click R to reset the scene so the object is once again in its original orientation. I found a script online that achieves this but it is also causing something weird with the lighting in the scene (directional light). When R is clicked the model resets but it appears much darker than when the user originally presses play. In the lights properties I notice that before the reset it's y rotation is set to -30 and after the reset it is set to 330, the angle of the light doesnt seem to have changed though so I dont understand why that would change the lighting of the model.
    I am using the latest issue of Unity 5, below is the code I used that is causing the lighting issue.

    using UnityEngine;
    using System.Collections;

    public class ReloadOnClick : MonoBehaviour {

    void Update ()
    {
    if(Input.GetKeyDown (KeyCode.R))//if hit R Key
    {
    Application.LoadLevel(Application.loadedLevel);
    }
    }
    }
     
  2. jaasso

    jaasso

    Joined:
    Jun 19, 2013
    Posts:
    64
    does it happen when you make a build, or just in the editor? ive noticed that in the editor it doesnt calculate the light stuff or something like that if you load scenes from code, but works in build