- Home /
Restart UI-Button not working
Hello, I'm trying to figure out how to make a restart UI-button, so when i click it with the mouse the scene restarts. I have tried following another thread but it didn't really work for me. I have made a script and assigned it to the "On Click()" tab of the "Button". I have also made a GameObject I call "RestartObject" and placed it as a child of the button and added the script to it. Here's the script, i tried adding a (if button "some-button" is pushed) and I got it working. But for some reason it won't work when i try it with the UI.
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
public class Restart : MonoBehaviour {
// Use this for initialization
void Start ()
{
![alt text][1]
}
// Update is called once per frame
public void RestartGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
I appreciate all the help I can get, thanks in advance!
[1]: /storage/temp/112293-problem-with-ui.png
Answer by Chik3r · Mar 02, 2018 at 10:44 PM
You aren't selecting a function for the button. And in the dropdown select Restart>RestartGame
Your answer
Follow this Question
Related Questions
UI buttons are clickable but not performing task after go back to main menu 1 Answer
UI Button not correctly working 0 Answers
UI Element Got & Lost Focus Handling 2 Answers
Dynamically set the sprite of a button in loop 0 Answers
Subclassing Button, public variable won't show up in the inspector 5 Answers