Hi again, I’m trying to use these 2 scripts:
Javascript one:
var skinGUI : GUISkin; var logoTexture : Texture2D; var LoadingScreen : LoadingScreen = null; function Start() { LoadingScreen = new LoadingScreen(); } function theFirstMenu() { GUI.BeginGroup(Rect(Screen.width / 2 - 150, Screen.height / 2, 300, 200)); GUI.Box(Rect(0, 0, 300, 100), ""); if(GUI.Button(Rect(55, 18, 180, 40), "Start game")) { LoadingScreen.Load("Main Scene"); } if(GUI.Button(Rect(55, 52, 180, 40), "Quit")) { Application.Quit(); } GUI.EndGroup(); } function OnGUI () { GUI.skin = skinGUI; theFirstMenu(); }
C Sharp one:
using UnityEngine; public class LoadingScreen : MonoBehaviour { public Texture2D texture; static LoadingScreen instance; void Awake() { if (instance) { Destroy(gameObject); return; } instance = this; gameObject.AddComponent().enabled = false; guiTexture.texture = texture; transform.position = new Vector3(0.5f, 0.5f, 0.0f); DontDestroyOnLoad(this); } public static void Load(int index) { if (NoInstance()) return; instance.guiTexture.enabled = true; Application.LoadLevel(index); instance.guiTexture.enabled = false; } public static void Load(string name) { if (NoInstance()) return; instance.guiTexture.enabled = true; Application.LoadLevel(name); instance.guiTexture.enabled = false; } static bool NoInstance() { if (!instance) Debug.LogError("Loading Screen is not existing in scene."); return instance; } }
But the console says:
“Assets/MainMenu/MainMenuScript.js(4,21): BCE0018: The name ‘LoadingScreen’ does not denote a valid type (‘not found’).”
Obs.: The 2 scripts are in the same folder.