Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objects in Scene dark after calling LoadScene/LoadLevel

I completed Unity's roll-a-ball tutorial and it works fine. I changed a couple of materials to make it look better. I also added a C# script that should restart the level when the player falls off of the ground (I disables the walls). I am using Unity 5.5.

It initially looks like this: Screenshot of Initial Level

But when I go off the edge and the level restarts, it looks like this: Screenshot of Reloaded Level It sometimes looks like this for a few seconds after opening unity when the editor is loading.

Here is the script:

using UnityEngine;
using System.Collections;

public class DeathTrigger : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }

    void OnTriggerEnter (Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
            Application.LoadLevel(Application.loadedLevel);
    }
}

Any ideas on what's causing this?

like image 992
Johnny Dollard Avatar asked Apr 13 '26 22:04

Johnny Dollard


1 Answers

The colors and materials are loaded. This is a lighting problem because lighliting is still calculating in the background. This will likely occur in the Editor only. This should not happen in the build.

Depending on your Unity version, you can fix this by going to Windows --> Lighting --> Settings then go to the Scene tab. Scroll down and disable Auto Generate checkbox then click the Generate Lightning button.

enter image description here

For older version of Unity with no Auto Generate checkbox, see here.

like image 191
Programmer Avatar answered Apr 15 '26 13:04

Programmer