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;
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.
If it doesn’t work make sure that the button is getting called by some Debug.Log() withing the restart function.
its dont works [97106-problem.png|97106] i write this and nothing debuged SceneManager.LoadScene(SceneManager.GetActiveScene().path); Debug.Log ("clicked");
Not sure what else would cause this. However, I do recommend referencing the objects instead of going off of string paths. String paths can get lost in a build, and software that is used to remove unused content, will not find those references. Can you create a Public GameObject Prefab field, and instantiate from that instead of from a call to Resources? (I'm not sure why this would cause it, but loading it a different way might have some impact.)
Good Idea, but also did not work im not sure how to fix this i know it is a render problem and maybe it is in the camera do you know if there is any config in the camera?
From what I see in images, you havn’t attached the script to a gameobject and you directly draged it from Project panel into the event slot in inspector (tell me if I’m wrong).
you need to drag the script on a gameobject and drag that gameobject into the slot in the event part of the button
i have added the the "restart.cs" script to an empty game object the putted it in the onclick ^ ^ but dont works !
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.
– Hellium