V
V
VladikK_9572020-04-25 20:26:32
Unity
VladikK_957, 2020-04-25 20:26:32

Error Unable to implicitly convert type 'UnityEngine.SceneManagement.Scene' how to fix?

I'm trying to make sure that the sound in my game is for 3 scenes. Found instructions.
https://docs.unity3d.com/ScriptReference/Object.Do... Everything is fine with the destroid, the music plays, but there are wild problems with the first superscript. Here is the script itself
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneSwap : MonoBehaviour
{
private void OnGUI()
{
int xCenter = (Screen.width / 2);
int yCenter = (Screen.height / 2);
int width = 400;
int height = 120;

GUIStyle fontSize = new GUIStyle(GUI.skin.GetStyle("button"));
fontSize.fontSize = 32;

Scene scene = SceneManager.GetActiveScene();

if (scene.name == "scene1")
{
// Show a button to allow scene2 to be switched to.
if (GUI.Button(new Rect(xCenter - width / 2, yCenter - height / 2, width, height), "Load second scene", fontSize))
{
SceneManager.LoadScene("scene2");
}
}
else
{
// Show a button to allow scene1 to be returned to.
if (GUI.Button(new Rect(xCenter - width / 2, yCenter - height / 2, width, height), "Return to first scene", fontSize))
{
SceneManager.
}
}
}
}
Error Unable to implicitly convert the type "UnityEngine.SceneManagement.Scene"
And I suppose if you fix it and hang it at the beginning and end, then the song will stop? new music for each scene is not the point)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question