Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
-1
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
Add comment · 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

· Add your reply
  • Sort: 
avatar image
0

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
Add comment · 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
0

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

Why is your script commented out?

Comment
Add comment · 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
0

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
Add comment · 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

Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().path); Debug.Log ("clicked");

problem.png (201.3 kB)
avatar image
0

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
Add comment · 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
0

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

Same code, but working with Unity 5.6.0f3

Comment
Add comment · 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
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

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

Creating a Restart Button 3 Answers

Simple Restart not working 0 Answers

void dont show up in on click 1 Answer

Canvas button with 2 functions onClick must be pressed twice for 2nd function? Will not disappear? 1 Answer

button OnClick function triggering another buttons OnClick 0 Answers


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