user3418522
user3418522

Reputation: 9

Having trouble with a C# Script

When I save my script, it comes up with these errors:

Assets/Player Controller.cs(38,128): error CS1526: A new expression requires () or [] after type.

and this

Assets/Player Controller.cs(38,129): error CS8032: Internal compiler error during parsing, Run with -v for details.

I have researched it, but no answer. can someone please help? the problem is on this line:

GUI.TextField (new Rect (Screen.width / 2 - 65, Screen.height / 2 - 11, 130, 22) "Do something to start"); }

Upvotes: 0

Views: 299

Answers (1)

J0e3gan
J0e3gan

Reputation: 8938

You are missing a comma between the Rect and string arguments to the GUI.TextField(Rect, string) constructor.

Try this instead:

GUI.TextField (new Rect (Screen.width / 2 - 65, Screen.height / 2 - 11, 130, 22), "Do something to start"); }

Also, consider formatting across multiple lines to make the structure a bit clearer (and errors like this a bit easier to spot):

    GUI.TextField(
        new Rect(Screen.width / 2 - 65, Screen.height / 2 - 11, 130, 22),
        "Do something to start");
}

Upvotes: 4

Related Questions