- Home /
Help Solve This
Please help solve this script error it keeps saying unexpected symbol { but I dont see anything wrong. Its a simple texture button script.
using UnityEngine; using System.Collections;
public class GUIButton : MonoBehaviour {
public Texture2D texture = null;
private void OnGUI(){
if(GUI.Button(new Rect(Screen.width/2 -63,Screen.height/2 -63,texture.width, texture)){
Application.LoadLevel(1);
}
}
}
Answer by roojerry · Jan 24, 2014 at 09:40 PM
missing a )
if(GUI.Button(new Rect(Screen.width/2 -63,Screen.height/2 -63,texture.width, texture))){
Thanks I was going crazy for a $$anonymous$$ute lol
No Problem. $$anonymous$$ark this as the correct answer to close this question please
didnt work now it says Overload method match for Rect(screen etc.
You should be sending 4 floats as arguments to new Rect. Check the last argument. I assume you meant texture.height
Your last argument isn't of a type that can be implicitly converted to a float. You probably meant to use texture.height ins$$anonymous$$d of just texture. if(GUI.Button(new Rect(Screen.width/2 -63,Screen.height/2 -63,texture.width, texture.height))){
Answer by Dan Deibler · Jan 24, 2014 at 09:43 PM
You're missing a closing parenthesis on line 5. You have 3 opening but only 2 closing.
"edited 10 $$anonymous$$utes ago" "answered 3 $$anonymous$$utes ago" It's going to take me some time to adjust to the unique temporal mechanics of this place.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Script error help! 1 Answer
Scripting error #2! 2 Answers
what is wrong with this online FPS script(not done) ? 1 Answer
GUI cale and position according to the actual screen resolution. 1 Answer