I want to have a text element at the beginning of each level stating the level the player is about to play, this text element should disappear at the moment the player clicks on the mouse to launch the ball. I have tried several approaches in both the levelmanager and losecollider scripts, but i didnt get it to work. Making the text appear is easy , but I cant find the method to make it go away on the mouseclick. Cant figure out what element and how to call on it to create that function. This is my Losecollider script:
using UnityEngine;
using System.Collections;
public class LoseCollider : MonoBehaviour {
public static int numLives;
public static bool firstLevelLoaded = true;
private LevelManager levelManager;
private void Start() {
if (firstLevelLoaded) {
numLives = 5;
firstLevelLoaded = false;
}
}
public void OnTriggerEnter2D(Collider2D trigger) {
levelManager = GameObject.FindObjectOfType<LevelManager>();
numLives--;
if (numLives < 0) {
levelManager.LoadLevel("Lose");
firstLevelLoaded = true;
}else {
GameplayController.instance.Countlives(numLives);
Ball.instance.SetBallPosition();
}
}
public void OnCollisionEnter2D (Collision2D collision) {
}
}
and this is my Levelmanager script:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class LevelManager : MonoBehaviour {
public void LoadLevel(string name){
Brick.breakableCount = 0;
SceneManager.LoadScene(name);
}
public void QuitRequest(){
Debug.Log("I want to quit");
Application.Quit ();
}
public void LoadNextLevel() {
Brick.breakableCount = 0;
SceneManager.LoadScene(sceneBuildIndex: Application.loadedLevel + 1);
}
public void BrickDestroyed() {
if (Brick.breakableCount <= 0) {
LoadNextLevel();
}
}
}
All tips and trics are welcome.
Thanks.