- Home /
Can I deactivate a messagebox without any scripting?
Greetings to you all!
I did some research about my problem in advance through Google, but I found only solutions WITH scripting.
Today I started to build up my first "something" I could call a game at some day, if I'm up to see it to the end.
From a button and a message box tutorial videos in YouTube I learned to make basic buttons and two basic(?) message boxes.
Through poking around between the button object and a panel with text in it I was able to open a message box through clicking a button. I did this without scripting, since I kinda like the way to get stuff working without scripting (as long as I can help to avoid it).
So, through the GameObject.SetActive -command (chosen from the dropdown list) I managed to open the message box. I added an X-button on the messagebox and hoped to find a function similar to mentioned before to do the reverse action - again, without coding.
To my slight astonishment however, I didn't see any of the sort. I couldn't find any alternative function available in the dropdown list to my little X-button in my message box to close my message box. (Or I couldn't know/understand that any of the given commands could do the trick)
Is there any way to get a function to close a message box (through a button inside the message box) without coding? If not, I need to figure out, how to code the function and how to add it in the right place =(
Thanks in advance!
(I also wish to be able to reopen that message box when you click the same button, so I am not looking for options to completely/fully disable the message box)
Isn't there a little checkbox next to the buttons SetActive event? I believe there should be, if it's set to unchecked it will disable the message, making it invisble.
Answer by TheSOULDev · Sep 10, 2017 at 12:28 PM
Unless you literally have a full "for dummies" engine in Unity (like RPG Maker), you won't be able to do anything significant without scripting. To make a messagebox close when a button is pressed in the same message box, add a button component to the game object you want to act as a button, then open up your message box script, add a function that looks something like this:
public void CloseMessageBox(GameObject MessageBox)
{
MessageBox.SetActive(false);
return;
}
And add that method to the button component OnClick() Unity Event.
If you want the function to act as a toggle, use this:
public void ToggleMessageBox(GameObject MessageBox)
{
MessageBox.SetActive(!MessageBox.activeSelf);
return;
}
Your answer
Follow this Question
Related Questions
how can I disapear a button after push? 1 Answer
GUI Button scripting 0 Answers
Children of DualTouchControls prefab keep being forced to active 0 Answers
Button onClick based on image (sprite) on Button 1 Answer
Button press for Animations 1 Answer