Version: 2022.3
public SceneManagement.Scene scene ;

描述

该 GameObject 所属的场景。

//Output the name of the Scene this GameObject belongs to

using UnityEngine; using UnityEngine.SceneManagement;

public class Example : MonoBehaviour { void Start() { Scene scene = gameObject.scene; Debug.Log(gameObject.name + " is from the Scene: " + scene.name); } }

Did you find this page useful? Please give it a rating: