LoginSignup
23
14

More than 5 years have passed since last update.

Unityで現在のシーン名の取得方法

Posted at

Unityで現在のシーン名を取得するためのメモ

環境

・OS X 10.11.6(El Capitan)
・Unity 5.4.0f3

コード

SceneManager.GetActiveScene().name

でString型で現在のシーン名を取得できる。

サンプルコード

test.cs
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement; // コレ重要

public class HogeHoge : MonoBehaviour {

    void Update () {
        if(SceneManager.GetActiveScene().name == "hogehoge"){ // hogehogeシーンでのみやりたい処理

        }else{ // それ以外のシーンでやりたい処理

        }
    }

}

23
14
1

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
23
14