【问题标题】:When I reload my game scene the objects do not reload in unity当我重新加载我的游戏场景时,对象不会统一重新加载
【发布时间】:2018-02-23 12:29:20
【问题描述】:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{
    Scene scene;
    private void Awake()
    {
        scene = SceneManager.GetActiveScene();
    }

    public void LoadScene(string level)
    {
        if (level == "Game")
        {
            SceneManager.LoadScene("Game");

        }
        else
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(level);
        }
    }
}

当它重新加载游戏场景时,对象是静止的,就像场景结束时一样。

【问题讨论】:

  • 在LoadScene DestroyObject(GameObject.Find("ObjectsToBeDestroyed"))之后使用这个;

标签: c# unity3d


【解决方案1】:

你所做的应该是有效的。

唯一不会重新加载的对象是那些具有包含DontDestroyOnLoad 的脚本的对象。您应该检查您的对象是否属于这种情况

顺便说一句,你的 if-else 块是没用的,它们的作用和你写的一样

public void LoadScene(string level)
{
    SceneManager.LoadScene(level);
}

【讨论】:

    【解决方案2】:

    如果对象显示在场景视图中但不在层次结构中,则应检查场景是否折叠。如果是这样,请单击场景名称左侧的箭头。

    【讨论】:

      猜你喜欢
      • 2022-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-11
      • 2015-12-02
      • 2020-05-18
      • 2021-12-24
      • 1970-01-01
      相关资源
      最近更新 更多