Hello,
I wrote script for player movement. I use same script for different playable characters. Each different character is in different scenes. In player movement script I included double jump too, but I don’t want to have first player double jump and I want to have other double jump.
I want to write something like that,
If(Scene2) {
}
So, how should I write if scene 2 is loaded statement? Sorry for my bad English, hope you understand what I meant.
Hi there @Kobaxidze
To check what scene is currently open you can make use of the SceneManagement namespace provided by Unity. Using the SceneManager class you can retrieve the currently active scene in the game and store it into a temporary variable which you can then use to check either it’s name or build index in a conditional. For example:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class ExampleClass : MonoBehaviour
{
void Start ()
{
// Create a temporary reference to the current scene.
Scene currentScene = SceneManager.GetActiveScene ();
// Retrieve the name of this scene.
string sceneName = currentScene.name;
if (sceneName == "Example 1")
{
// Do something...
}
else if (sceneName == "Example 2")
{
// Do something...
}
// Retrieve the index of the scene in the project's build settings.
int buildIndex = currentScene.buildIndex;
// Check the scene name as a conditional.
switch (buildIndex)
{
case 0:
// Do something...
break;
case 1:
// Do something...
break;
}
}
}
Every time this object is started within a new scene it will grab the current scene and check it’s name and build index which you can then use to perform conditional logic based upon the currently open scene. Below are some links to the Scripting API.
GetActiveScene() - Scripting API
Scene Class - Scripting API
I hope this helps! 
SceneManager.GetSceneByName(string).isLoaded
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.GetSceneByName.html
Works with multiple scenes for the Editor and at runtime 
I came to this thread in a search for an answer, but it didn’t satisfy me - I need to check if the specific scene is currently opened in a hierarchy (there could be many scenes currently loaded).
So, I used one of two variants depending if I am in Editor or Runtime:
#if UNITY_EDITOR
bool ifScene_CurrentlyLoaded_inEditor(string sceneName_no_extention) {
for(int i=0; i< UnityEditor.SceneManagement.EditorSceneManager.sceneCount; ++i) {
var scene = UnityEditor.SceneManagement.EditorSceneManager.GetSceneAt(i);
if(scene.name == sceneName_no_extention) {
return true;//the scene is already loaded
}
}
//scene not currently loaded in the hierarchy:
return false;
}
#endif
bool isScene_CurrentlyLoaded(string sceneName_no_extention) {
for(int i = 0; i<SceneManager.sceneCount; ++i) {
Scene scene = SceneManager.GetSceneAt(i);
if(scene.name == sceneName_no_extention) {
//the scene is already loaded
return true;
}
}
return false;//scene not currently loaded in the hierarchy
}
How @Cepheid said, you can do it allso by using
SceneManager.GetActiveScene().name
void Update()
{
if (SceneManager.GetActiveScene () == SceneManager.GetSceneByName (“scene1”))
{
SceneManager.LoadScene (“scene2”);
}
else if (SceneManager.GetActiveScene () == SceneManager.GetSceneByName ("scene2"))
{
SceneManager.LoadScene ("scene1");
}
}
well i figured this out… might someone is interested for switching between scenes. i used it for my player. (ontrigger enter load the opposite scene and there on same trigger back to main scene)
using UnityEngine;
using UnityEngine.SceneManagement;
public class Test : MonoBehaviour{
IEnumerator LoadSceneAdditive(int buildIndex)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(buildIndex, LoadSceneMode.Additive);
while (!operation.isDone)
{
yield return null;
}
//Do somethin
}
}