Reputation: 197
I want to create a PopUp for my game, my requirement is to open a popUp when user click a button. And popUp contains a image for its background, a close button on upper-right corner and two buttons on the popUp (lets say YES & NO). I make R&D but nothing found relevant. Any help would be appriciated.
P.S. I don't want to use any third party plugIn Like NGUI, 2D ToolKit etc.
Upvotes: 3
Views: 13848
Reputation: 2480
Unity till 4.5
You can build most components with GUITexture
wiht the legacy UI system.
http://docs.unity3d.com/Manual/class-GuiTexture.html
Build your background and buttons from textures of the scheme below. For the buttons you also use GUIText
and make the clickable/touchable.
For more info see the scripting guide.
http://docs.unity3d.com/Manual/GUIScriptingGuide.html
Unity 4.6 or newer
The GUI system of Unity easily allows you to do that. You will need a Canvas
and a Sprite
for the background. And two buttons as children for YES and NO.
See the introduction first http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/the-new-ui
The manual shows all components http://docs.unity3d.com/Manual/UISystem.html
GUI Reference http://docs.unity3d.com/ScriptReference/GUI.html
Upvotes: 3
Reputation: 1
Try creating something like this for the pop-up button(JavaScript):
var popupactive : boolean = false;
var (Name of the GUI window) : GUITexture;
var (Picture1) : GUITexture;
var (Picture2) : GUITexture;
var (Picture3) : GUITexture;
(Name off the GUI window).enabled = false;
(Picture1).enabled = false;
(Picture2).enabled = false;
(Picture3).enabled = false;
function OnMouseUp(){
if(popupactive==false){
popupactive = true;
}
else{
popupactive = false;
(Name of the GUI window).enabled = false;
}
}
Then try adding a function that closes the GUI for the exit button and "no" button to close the opened GUIs, Also remember to import the separate scripts assigned to the separate buttons inside the code! Remember also to assign them in the Unity editor. Hope it helps!
Upvotes: 0