SceneManager无法识别LoadSceneAsync

问题描述 投票:0回答:1

我从早期版本的Unity导入了一个项目,我目前正在使用2018.3

我有一个问题,我似乎无法忽略它,评论它给了我另一个错误

Assets \ Scripts \ Generals \ LoadController.cs(48,22):错误CS0117:'SceneManager'不包含'LoadSceneAsync'的定义

我没有一个名为'SceneManager'的已定义类,它覆盖了统一的SceneManager类

LoadController.cs

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;

 public string nameSceneLoad = "MainGame";
 void NextScene()
{
    CancelInvoke();
    SceneManager.LoadSceneAsync (nameSceneLoad, LoadSceneMode.Single);
}

如果我试图忽略它,我会有以下内容

资产\ Photon Unity Networking \ Editor \ PhotonNetwork \ PhotonViewHandler.cs(188,13):错误CS0433:类型'EditorSceneManager'存在于'Assembly-CSharp,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null'和'UnityEditor,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null'

PhotonViewHandler.cs

//TODO: check if this can be internal protected (as source in editor AND as 
dll)
public static void LoadAllScenesToFix()
{
string[] scenes = System.IO.Directory.GetFiles(".", "*.unity", 
SearchOption.AllDirectories);

foreach (string scene in scenes)
{
EditorSceneManager.OpenScene(scene);
PhotonViewHandler.HierarchyChange();//NOTE: most likely on load also 
triggers a hierarchy change
EditorSceneManager.SaveOpenScenes();
}
Debug.Log("Corrected scene views where needed.");
}

Screan有什么想法吗?

我尝试导航到F12导致的定义

#if !UNITY_MIN_5_3  && ! UNITY_2017 
// in Unity 5.3 and up, we have to use a SceneManager. This section re- 
implements it for older Unity versions

#if UNITY_EDITOR
namespace UnityEditor.SceneManagement
{
/// <summary>Minimal implementation of the EditorSceneManager for older 
Unity, up to v5.2.</summary>
public class EditorSceneManager
{
    public static int loadedSceneCount
    {
        get { return 
  string.IsNullOrEmpty(UnityEditor.EditorApplication.currentScene) ? -1 : 1; }
    }

    public static void OpenScene(string name)
    {
        UnityEditor.EditorApplication.OpenScene(name);
    }

    public static void SaveOpenScenes()
    {
        UnityEditor.EditorApplication.SaveScene();
    }

    public static void SaveCurrentModifiedScenesIfUserWantsTo()
    {
        UnityEditor.EditorApplication.SaveCurrentSceneIfUserWantsTo();
    }
}
}
#endif

 namespace UnityEngine.SceneManagement
{
 /// <summary>Minimal implementation of the SceneManager for older Unity, up 
to v5.2.</summary>
 public class SceneManager
  {
    public static void LoadScene(string name)
    {
        Application.LoadLevel(name);
    }

    public static void LoadScene(int buildIndex)
    {
        Application.LoadLevel(buildIndex);
    }
  }
 }

 #endif
c# unity3d photon
1个回答
1
投票

尝试告诉使用哪个,所以你可以绕过这个重复的EditorSceneManager错误

using foo = UnityEditor.EditorSceneManager;
using boo = otherdll.Namespace;

顺便说一下,我认为这个错误是因为你在.net 4.x中有一个dll而你的.net3.5中有你的dll,所以你可以jsut删除那个3.5。

© www.soinside.com 2019 - 2024. All rights reserved.