How to get the active/loaded Scene then turn the name of it into a string? [C#]
I am using Playerprefs to get ints and grab them for saving and such. And I have a very specific layout for it and to make it all come together I need to get the active scene and then turn the name of the active scene into a string that playerprefs can use.
Answer by hexagonius · Nov 19, 2016 at 03:54 AM
SceneManagement.SceneManager.GetActiveScene().name
Awesome, I might add, use either:
UnityEngine. Scene$$anonymous$$anagement.Scene$$anonymous$$anager.GetActiveScene().name;
using UnityEngine;
using System.Collections;
public class SceneName : $$anonymous$$onoBehaviour
{
void Start ()
{
string activeSceneName = UnityEngine.Scene$$anonymous$$anagement.Scene$$anonymous$$anager.GetActiveScene().name;
Debug.Log(activeSceneName);
}
}
OR using UnityEngine.Scene$$anonymous$$anagement;
using UnityEngine;
using UnityEngine.Scene$$anonymous$$anagement;
using System.Collections;
public class SceneName : $$anonymous$$onoBehaviour
{
void Start ()
{
string activeSceneName = Scene$$anonymous$$anager.GetActiveScene().name;
Debug.Log(activeSceneName);
}
}
Thank you so much! You've helped me a lot man! I was doing that, I just didn't put .name after the parenthesis. Huh, simple mistakes I guess
You're welcome @$$anonymous$$usic$$anonymous$$ing7, anytime ;)
Your answer
Follow this Question
Related Questions
How to prevent to save or send a big json string? 0 Answers
UNET Multiple online scenes 0 Answers
Saving an image's state 2 Answers
PlayerPrefs is affecting all builds of my game 1 Answer
How to Restart game (Menu and Game are in same Scene)? 1 Answer