- Home /
Question by
adam-albaw48 · Nov 30, 2020 at 10:38 PM ·
c#uipopup
I am trying to create a warning system for each possible error instead of Debug.Log
Script attached to game object:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class PopUpHandler : MonoBehaviour
{
public GameObject PopUp;
public Animator animatore;
public TMP_Text Warning;
public void PopUpWake(string text)
{
PopUp.SetActive(true);
Warning.text = text;
animatore.SetTrigger("Pop");
}
}
Script to access it:
public IEnumerator RegisterUser(string Username, string Password, string Email, string EmailCon)
{
WWWForm form = new WWWForm();
form.AddField("loginUser", Username);
form.AddField("loginPass", Password);
form.AddField("loginEmail", Email);
if(Email==EmailCon ){
using (UnityWebRequest www = UnityWebRequest.Post("http://localhost/SpaceCube/RegisterUser.php", form))
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log(www.downloadHandler.text);
if(www.downloadHandler.text== "New record created successfully" )
{
SceneManager.LoadScene("MainPage2");
}
}
}
}
else
{
Debug.Log("Email doesn't match confirmation");
---------->
}
Code I have tried where the arrow is above:
PopUpHandler warn = new PopUpHandler warn.PopUp.SetActive(true);
warn.Warning.text = "Email doesn't match confirmation";
warn.animatore.SetTrigger("Pop");
This didn't work. I also tried using findgameobjectwith tag but it said that that method didnt exist inside the gameobject class. Please help!
Comment
Your answer
Follow this Question
Related Questions
Click Screen To Access Hidden UI Menu 0 Answers
How to add a popup GUI on a specific level before the Win popup? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers