- Home /
Gui Button Not Working After a Scene Load
Hi to all Mainly to Moderators, Erich and Andee, I dont know whats going wrong,i have a scene which consists of below code.Below scene(with the below code attached) will be loaded only when player hits the enemy.But after loading the below scene, Gui buttons are not working.I've checked by putting break point and by print statement aswell but of no use. On a special Note Below code works like Charm Only when i run the scene Separately.
void OnGUI()
{
if(GUI.Button(new Rect(Screen.width*(0.01f*70f),Screen.height*(0.01f*20f),Screen.width*(0.01f*10f),Screen.height*(0.01f*10f)),"Play Again"))
{
print("Clicked");
Application.LoadLevel("GameScene");
}
}//This code is attached to main camera and will this scene will be loaded when player hits enemy.
//I am pretty sure that scene is loading but buttons are not working
//above Code works only when i run the scene(with the above code attached)SEPARATELY.
A big thanks to Unity and forum Members.
To what gameobject (and how) are you attaching this script or behaviour? When you load the scene (not separately) and inspect the gameobject that is supposed to have this code attached, does it actually have the component you expected? Initially I do not see any reasons why this should not work.
yes gameobject do have the above script attached...Bt a big thanks to you for ur reply..I have Solved the issue.Issue is that therz a another finger gesture reorganization script which made the above script not to work..I've solved it...Well thanks again bro senc01a
Can you please help me I am having the same problem.I am using the Daikon Forge GUI - Create Script Wizard this is the 2$$anonymous$$ tutorial: https://www.youtube.com/watch?v=06drrFD70zk. This is the code very similar to the one you used created by the Script Wizard:
public class press : $$anonymous$$onoBehaviour {
public void OnClick( dfControl control, df$$anonymous$$ouseEventArgs mouseEvent )
{
// Add event handler code here
Application.LoadLevel (1);
Debug.Log( "Click" );
}
}`
//$$anonymous$$y scene loads but buttons do not work and if I run the scene alone it works.Any help would be greatly appreciated. $$anonymous$$y game is a simple runner game just touch to make character jump.
Your answer
Follow this Question
Related Questions
Help with reloading scene for endless runner 2 Answers
Why does the CardboardVR Lollygagger project crash when loading a scene on a Nexus 4? 2 Answers
UI Button Instead of OnGUI Button? 1 Answer
Return to a scene rather than loading again 1 Answer
Unknown Identifier SceneManager/Obsolete Application.LoadLevel 1 Answer