using UnityEngine;
using UnityEngine.SceneManagement;
namespace LE_LevelEditor.Example
{
public class ExampleGame_SceneChecker : MonoBehaviour
{
private string m_errorMsg;
private void Start()
{
if (SceneManager.sceneCountInBuildSettings < 4)
{
m_errorMsg = "There is one more thing you have to do...\nPlease add\nLE_ExampleEditor\nLE_ExampleGame\nLE_ExampleDungeonEditorGame\nLE_ExampleEditorTerrainOnly\nscenes to your Build Settings.\nTo add a level to the build settings use the menu File->Build Settings...\n";
if (SceneManager.GetActiveScene().name != "LE_ExampleEditor")
{
m_errorMsg += "Without adding the example scenes to the Build Settings you will not be able to load the game scene when the 'Play' button is pressed!";
}
else
{
m_errorMsg += "Without adding the example scenes to the Build Settings you will not be able to load the editor scene when the 'Back To Editor' button is pressed!";
}
}
else
{
Object.Destroy(this);
}
}
private void OnGUI()
{
if (!string.IsNullOrEmpty(m_errorMsg))
{
GUI.depth = -10000;
Rect rect = new Rect((float)Screen.width * 0.1f, (float)Screen.height * 0.05f, (float)Screen.width * 0.8f, (float)Screen.height * 0.8f);
GUI.Box(rect, string.Empty);
GUI.Box(rect, string.Empty);
GUI.Box(rect, string.Empty);
GUI.Box(rect, string.Empty);
Rect position = new Rect(rect);
position.xMin += 35f;
position.xMax -= 35f;
position.yMin += 35f;
position.yMax -= 35f;
GUI.Label(position, m_errorMsg);
Rect position2 = new Rect(rect);
position2.yMin = position2.yMax;
position2.height = (float)Screen.height * 0.1f;
if (GUI.Button(position2, "Close"))
{
Object.Destroy(this);
}
}
}
}
}