I’m a beginner on unity and I have this problem:
UnassignedReferenceException: The variable TEXT1 of Player has not been assigned
And this is my main script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Player : MonoBehaviour {
public GameObject camcam;
public GameObject score;
public GameObject Button;
public GameObject PANEL1;
public GameObject TEXT1;
public GameObject TEXT2;
public int scoremac;
public double Ytodie;
public string NextLVL;
public string ThisLVL;
public static int pointage = 0;
void Start() {
PANEL1 = GameObject.FindWithTag("Panel");
TEXT1 = GameObject.FindWithTag("txt1");
TEXT2 = GameObject.FindWithTag("txt2");
pointage = 0;
PANEL1.SetActive(false);
TEXT1.SetActive(false);
TEXT2.SetActive(false);
score.GetComponent<Text>().text = "Score: " + pointage;
Button.SetActive(false);
}
// Update is called once per frame
void Update()
{
AdjustCam();
CheckKeys();
CheckScore();
CheckifFall();
}
bool boff = false;
void CheckifFall()
{
if(boff == false)
{
if (gameObject.transform.position.y < Ytodie)
{
StartCoroutine(Timer2());
}
}
}
public void OnClick()
{
TEXT1.SetActive(true);
TEXT2.SetActive(true);
PANEL1.SetActive(true);
StartCoroutine(LoadLevelsPro());
}
IEnumerator Timer2()
{
yield return new WaitForSeconds(1);
pointage = 0;
SceneManager.LoadScene(ThisLVL);
}
IEnumerator LoadLevelsPro()
{
Button.SetActive(false);
yield return new WaitForSeconds(1);
AsyncOperation loading = SceneManager.LoadSceneAsync(NextLVL);
while (!loading.isDone)
{
yield return null;
}
}
void CheckScore()
{
if (pointage <= scoremac)
{
score.GetComponent<Text>().text = "Score: " + pointage;
}
else
{
score.GetComponent<Text>().color = Color.green;
score.GetComponent<Text>().text = "Victoire!";
boff = true;
Button.SetActive(true);
}
}
void CheckKeys()
{
float mouvHorizontal = Input.GetAxis("Horizontal");
float mouvVertical = Input.GetAxis("Vertical");
Vector3 mouvement = new Vector3(mouvHorizontal, 0, mouvVertical);
gameObject.GetComponent<Rigidbody>().AddForce(mouvement * 120 * Time.deltaTime);
}
void AdjustCam()
{
camcam.transform.position = new Vector3(gameObject.transform.position.x,
gameObject.transform.position.y + 5,
gameObject.transform.position.z - 10);
}
}
This is an example: