解決這個問題非常簡單
不需要一行一行地修改代碼,直接 Ctrl + A / C / V 完整地替換掉兩個C#腳本的代碼即可。
這兩個需要替換的腳本是
ForceReset.cs
SimpleActivatorMenu.cs
首先,創建一個平面
點擊運行,發現出現如下錯誤
error CS0691
因為unity標准資源包是2017的,我們用的是2019的新版,在新版中GUIText組件已經棄用了,而Asset商店里還沒有及時更新,所以需要手動修改腳本
雙擊第一個錯誤,用編輯器打開
找到這兩個待修改的腳本
原來的 ForceReset.cs 腳本是
現在要改成
using System; using UnityEngine; using UnityEngine.SceneManagement; using UnityStandardAssets.CrossPlatformInput; using UnityEngine.UI; [RequireComponent(typeof (Image))] public class ForcedReset : MonoBehaviour { private void Update() { // if we have forced a reset ... if (CrossPlatformInputManager.GetButtonDown("ResetObject")) { //... reload the scene SceneManager.LoadScene(SceneManager.GetSceneAt(0).name); } } }這樣,錯誤就消失了
還有一個錯誤就是 SimpleActivatorMenu.cs 腳本
雙擊打開
改為
using System; using UnityEngine; using UnityEngine.UI; namespace UnityStandardAssets.Utility { public class SimpleActivatorMenu : MonoBehaviour { // An incredibly simple menu which, when given references // to gameobjects in the scene public Text camSwitchButton; public GameObject[] objects; private int m_CurrentActiveObject; private void OnEnable() { // active object starts from first in array m_CurrentActiveObject = 0; camSwitchButton.text = objects[m_CurrentActiveObject].name; } public void NextCamera() { int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1; for (int i = 0; i < objects.Length; i++) { objects[i].SetActive(i == nextactiveobject); } m_CurrentActiveObject = nextactiveobject; camSwitchButton.text = objects[m_CurrentActiveObject].name; } } }剩余的錯誤都是索引的錯誤,不影響,直接清除就好。
附:






