獲取當(dāng)前場(chǎng)景的名稱(chēng)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Test001 : MonoBehaviour {
void OnGUI(){
Scene scene = SceneManager.GetActiveScene ();
GUILayout.Label ("當(dāng)前場(chǎng)景: " + scene.name);
}
}
假如當(dāng)前場(chǎng)景創(chuàng)建后還沒(méi)有保存則不會(huì)顯示出名字屡贺。
舊寫(xiě)法:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test001 : MonoBehaviour {
void OnGUI(){
GUILayout.Label ("當(dāng)前場(chǎng)景: " + Application.loadedLevelName);
}
}