- Home /
how to do a Popup window when the answer are correct
hello everyone! I am new to unity. I am trying to make a simple 2D mobile based game using unity. Now i am stuck at when the play drag and drop all the box correctly, there will have a popup window to show the player that level is completed, can move to new level. i have been trying searched at website and did the coding by myself, but still can't work... Anyone can help me? Below is the coding for the player dragging the box:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Manager : MonoBehaviour
{
public GameObject first, second, third, forth, first_black, second_black, third_black, forth_black;
Vector2 firstInitialPos, secondInitialPos, thirdInitialPos, forthInitialPos;
private void Start()
{
firstInitialPos = first.transform.position;
secondInitialPos = second.transform.position;
thirdInitialPos = third.transform.position;
forthInitialPos = forth.transform.position;
}
public void DragFirst()
{
first.transform.position = Input.mousePosition;
}
public void DragSecond()
{
second.transform.position = Input.mousePosition;
}
public void DragThird()
{
third.transform.position = Input.mousePosition;
}
public void DragForth()
{
forth.transform.position = Input.mousePosition;
}
public void DropFirst()
{
float Distance = Vector3.Distance(first.transform.position, first_black.transform.position);
if(Distance<50)
{
first.transform.position = first_black.transform.position;
}
else
{
first.transform.position = firstInitialPos;
}
}
public void DropSecond()
{
float Distance = Vector3.Distance(second.transform.position, second_black.transform.position);
if (Distance < 50)
{
second.transform.position = second_black.transform.position;
}
else
{
second.transform.position = secondInitialPos;
}
}
public void DropThird()
{
float Distance = Vector3.Distance(third.transform.position, third_black.transform.position);
if (Distance < 50)
{
third.transform.position = third_black.transform.position;
}
else
{
third.transform.position = thirdInitialPos;
}
}
public void DropForth()
{
float Distance = Vector3.Distance(forth.transform.position, forth_black.transform.position);
if (Distance < 50)
{
forth.transform.position = forth_black.transform.position;
}
else
{
forth.transform.position = forthInitialPos;
}
}
}
Answer by tormentoarmagedoom · Feb 21, 2020 at 04:18 PM
Hello There. I dont understand what are you asking for exactly... Creating a popup window is so simple. You first need to create a new canvas and design the window. Then just need to SetActive() (true ir false) the object whne neccessary.
If not asking for this, please be more specyfic...
If you are asking for a whole code for popup, animationm scene change, etc... then remake the post asking ONLY one thing, multiple requests posts will be deleted.
Bye!
I think I’m having the same problem, upon entering the correct answer on a quiz game I’d like to have a panel pop up where you’d have the next question button and also a “congratulations”/“well done” text. Hope that was a bit clearer, thanks.