SceneManager 无法识别 LoadSceneAsync
SceneManager can't recognize LoadSceneAsync
我从早期版本的Unity导入了一个项目,我目前使用的是2018.3
我有一个问题,我似乎无法忽略它,评论它给了我另一个错误
Assets\Scripts\Generals\LoadController.cs(48,22): error CS0117: 'SceneManager' does not contain a definition for 'LoadSceneAsync'
我没有定义一个名为 'SceneManager' 的 class 覆盖统一场景管理器 Class
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);
}
如果我试图忽略它,我将得到以下结果
Assets\Photon Unity Networking\Editor\PhotonNetwork\PhotonViewHandler.cs(188,13): error CS0433: The type 'EditorSceneManager' exists in both 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' and '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.");
}
有什么想法吗?
我试过导航到定义 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
尝试指定使用哪一个来绕过重复的 EditorSceneManager
错误,如下所示:
using foo = UnityEditor.EditorSceneManager;
using boo = otherdll.Namespace;
顺便说一句,我认为这个错误是因为你有一个 .NET 中的 DLL 4.x 和一个以前的 .NET 3.5 中的 DLL,所以你可以删除 3.5 的那个。
我从早期版本的Unity导入了一个项目,我目前使用的是2018.3
我有一个问题,我似乎无法忽略它,评论它给了我另一个错误
Assets\Scripts\Generals\LoadController.cs(48,22): error CS0117: 'SceneManager' does not contain a definition for 'LoadSceneAsync'
我没有定义一个名为 'SceneManager' 的 class 覆盖统一场景管理器 Class
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);
}
如果我试图忽略它,我将得到以下结果
Assets\Photon Unity Networking\Editor\PhotonNetwork\PhotonViewHandler.cs(188,13): error CS0433: The type 'EditorSceneManager' exists in both 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' and '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.");
}
我试过导航到定义 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
尝试指定使用哪一个来绕过重复的 EditorSceneManager
错误,如下所示:
using foo = UnityEditor.EditorSceneManager;
using boo = otherdll.Namespace;
顺便说一句,我认为这个错误是因为你有一个 .NET 中的 DLL 4.x 和一个以前的 .NET 3.5 中的 DLL,所以你可以删除 3.5 的那个。