3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

`SceneManager' does not contain a definition for `LoadScene'

Posted at

しょうもない話だったけど備忘録的に。

Unityで制作中にこんなエラーがConsoleに。

`SceneManager' does not contain a definition for `LoadScene'

「あれ……ネット上のサンプル参考にしてるから間違ってないはずなんだけど……」と思いつつスクリプトを眺めていました。
コードはこんな感じ。Oculus Goのコントローラーの入力を受けて次のシーンに移るというもの。

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

public class SceneManager : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger)) {
			SceneManager.LoadScene(1);
		}
	}
}

SceneManager#LoadScene()はあるはずなのにな……と悩むこと一日。気づきました。
SceneManagerというクラス名がUnityEngine.SceneManagement.SeneManagerと名前衝突してる!
単純な話でしたね。ハイ。クラス名を独自のものに変更して解決です。

public class HogeSceneManager : MonoBehaviour 
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?