我从早期版本的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,版本= 0.0.0.0,文化=中性,PublicKeyToken =空”
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