调用 LoadScene/LoadLevel 后场景中的对象变暗 [英] Objects in Scene dark after calling LoadScene/LoadLevel

查看:35
本文介绍了调用 LoadScene/LoadLevel 后场景中的对象变暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了 Unity 的滚球教程,效果很好.我更改了一些材料以使其看起来更好.我还添加了一个 C# 脚本,当玩家从地面上掉下来时,它应该重新启动关卡(我禁用了墙壁).我使用的是 Unity 5.5.

它最初看起来像这样:

但是当我离开边缘并且关卡重新启动时,它看起来像这样:有时在编辑器加载时打开 unity 后几秒钟会出现这样的情况.

这是脚本:

使用UnityEngine;使用 System.Collections;公共类死亡触发器:MonoBehaviour {//用于初始化无效开始(){}//每帧调用一次更新无效更新(){}void OnTriggerEnter(对撞机其他){如果(other.gameObject.CompareTag(玩家"))Application.LoadLevel(Application.loadedLevel);}}

对导致这种情况的原因有什么想法吗?

解决方案

颜色和材质已加载.这是一个光照问题,因为光照仍在后台计算.这很可能发生在编辑器中.这应该发生在构建中.

根据您的 Unity 版本,您可以通过转到 Windows --> Lighting --> Settings 然后转到场景标签.向下滚动并禁用自动生成复选框,然后单击生成闪电按钮.

对于没有自动生成复选框的旧版 Unity,请参阅此处.>

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?

解决方案

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.

这篇关于调用 LoadScene/LoadLevel 后场景中的对象变暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆