Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In C#
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class RestartNow : MonoBehaviour {
- void OnGUI () {
- if (GUILayout.Button ("Restart")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- if (GUI.Button (new Rect (10,30,75,20), "Restart")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- }
- void Update () {
- if (Input.GetKey ("r")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- //Requires this button to be set in the Input Manager
- //http://unity3d.com/support/documentation/Manual/Input.html
- //http://unity3d.com/support/documentation/Components/class-InputManager.html
- if (Input.GetButtonDown ("Restart")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- }
- }
- // Or in UnityScript.js:
- function OnGUI () {
- if (GUILayout.Button ("Restart")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- if (GUI.Button (new Rect (10,30,75,20), "Restart")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- }
- function Update () {
- if (Input.GetKey ("r")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- // Requires this button to be set in the Input Manager
- // http://unity3d.com/support/documentation/Manual/Input.html
- // http://unity3d.com/support/documentation/Components/class-InputManager.html
- if (Input.GetButtonDown ("Restart")) {
- Application.LoadLevel(Application.loadedLevel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement