Objects in Scene dark after calling LoadScene/LoadLevel

风格不统一 提交于 2019-12-17 03:45:47

问题


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:

But when I go off the edge and the level restarts, it looks like this: 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?


回答1:


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.

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



来源:https://stackoverflow.com/questions/42447869/objects-in-scene-dark-after-calling-loadscene-loadlevel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!