• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Hamilcar-games · Jun 26, 2017 at 09:43 PM · buttoncanvasonclickrestartrestart game

i have a button to restart the same scene but it dont works (with images)

i have many many things but no one of them worked

i had created an empty gameobject and attached this script to it then put the gameobject into the button's ONCLICK and then choosen the public function of the script

then when i play the the game the button dont work i dont understand why

i have only one scene and when the players die the button be activated 'i have done this in onother script" i click the button to restart the scene...

this is he script:

using UnityEngine.SceneManagement; using UnityEngine;

public class RESTART : MonoBehaviour {

 public void restart()
 {
     //SceneManager.LoadScene (SceneManager.GetActiveScene ().name);

     //Scene loadedLevel = SceneManager.GetActiveScene ();
     //SceneManager.LoadScene (loadedLevel.buildIndex);


     SceneManager.LoadScene("GAME");


     //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     
 }

}

alt text

problem.png (201.3 kB)
Comment
Hellium

People who like this

-1 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Jul 02, 2017 at 09:22 PM 0
Share

Are you sure you have an EventSystem in your scene ? No other element which could block the raycast ? During play mode, select the EventSystem in your scene, put the pointer over the button and check in the little "Preview" box at the bottom of the Inspector that you have the name of your button.

avatar image Hamilcar-games Hellium · Jul 04, 2017 at 12:36 PM 0
Share

yes i have a event system

alt text

event-system.png (57.3 kB)

7 Replies

  • Sort: 
avatar image

Answer by Cycy · Jun 28, 2017 at 02:49 PM

Hi !

Is your scene in the "Scenes in build" list (in the built settings window) ?

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hamilcar-games · Jul 02, 2017 at 07:19 PM 0
Share

yes and its index is 0

i have only one scene for now

avatar image

Answer by Bren0831 · Jul 02, 2017 at 09:09 PM

Why is your script commented out?

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hamilcar-games · Jul 04, 2017 at 12:19 PM 0
Share

i tryed all of this comment but no one works

avatar image

Answer by Ashokkumar-M · Jul 03, 2017 at 05:39 AM

Try using the following code:

 SceneManager.LoadScene(SceneManager.GetActiveScene().path);

@dasfuhrer

If it doesn't work make sure that the button is getting called by some Debug.Log() withing the restart function.

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hamilcar-games · Jul 04, 2017 at 12:26 PM 0
Share

its dont works

alt text

i write this and nothing debuged

SceneManager.LoadScene(SceneManager.GetActiveScene().path); Debug.Log ("clicked");

problem.png (201.3 kB)
avatar image

Answer by efeguclu · Jul 04, 2017 at 12:31 PM

 SceneManager.LoadScene (SceneManager.GetActiveScene ().name);

this has to work?

if it's not working try that

 Application.LoadLevel(0);
Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hamilcar-games · Jul 04, 2017 at 09:22 PM 0
Share

this is old ! im with unity 5.5

avatar image

Answer by isbdnt · Jul 05, 2017 at 01:19 AM

Same code, but working with Unity 5.6.0f3

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

86 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make it so only a certain section of a button will work on click 1 Answer

Button Canvas OnClick no LoadScene 1 Answer

Creating a Restart Button 3 Answers

Simple Restart not working 0 Answers

void dont show up in on click 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges