Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by TheSamari3397 · Jul 29, 2013 at 10:41 PM · menupausejavascripting

I got a bunch of errors that make no sense to me. Help.

This is for a pause menu and I got a lot of unreasonable errors. I am also trying to get a foothold in Java scripting. These are the errors.

Assets/Scripts/PauseMenu.js(1,24): BCE0043: Unexpected token: :.

Assets/Scripts/PauseMenu.js(3,9): BCE0043: Unexpected token: public.

Assets/Scripts/PauseMenu.js(3,15): UCE0001: ';' expected. Insert a semicolon at the end.

Assets/Scripts/PauseMenu.js(3,23): UCE0001: ';' expected. Insert a semicolon at the end.

Assets/Scripts/PauseMenu.js(5,17): BCE0043: Unexpected token: Rect.

Assets/Scripts/PauseMenu.js(6,17): BCE0043: Unexpected token: boolean.

Assets/Scripts/PauseMenu.js(6,39): BCE0043: Unexpected token: ,.

Assets/Scripts/PauseMenu.js(6,40): UCE0001: ';' expected. Insert a semicolon at the end.

Assets/Scripts/PauseMenu.js(8,17): BCE0043: Unexpected token: void.

Assets/Scripts/PauseMenu.js(8,29): UCE0001: ';' expected. Insert a semicolon at the end.

Assets/Scripts/PauseMenu.js(10,28): BCE0044: expecting :, found '='.

This is the code I scripted. Thanks for the help.

 public class pauseMenu : MonoBehavior;
 {
     public GUISkin myskin;
     
     private Rect windowRect;
     pricate bool paused = false, waited = true;
     
     pricate void Start()
     {
         windowRect = new Rect(Screen.width/2-100, Screen.height/2-100,200,200);
     }
     
     private void waiting()
     {
         waited = true;
     }
     
     private void Update()
     {
         if (waited)
             if (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P))
             {
                 if (paused)
                     paused = false;
                 else
                     paused = true;
                 waited = false;
                 Invoke("waiting",0.3f);
             }
             
         if(paused)
             Time.timeScale =0;
         else
             Time.timeScale =1;
         
     }
     
     
     private void OnGUI()
     {
         if (paused)
             windowRect = GUI.Window(0,windowRect,windowFunc, "Pause Menu");
     }
     
     private void windowFunc(int id)
     {
         if(GUILayout.Button("Resume"))
         {
             paused = false;
         }
         GUILayout.BeginHorizontal();
         if(GUILayout.Button("Options"))
         {}
         if(GUILayer.Button("Main Menu"))
         {}
         GUILayout.EndHorizontal();
     }
 }
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jamora · Jul 29, 2013 at 10:42 PM

Remove the semicolon ( ; ) from after MonoBehaviour on the first line. Class declaration is not a statement, so it should not have a semicolon, which indicates a statement has ended. Otherwise this code looks like it would compile.

Comment
Add comment · Show 6 · 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 TheSamari3397 · Jul 29, 2013 at 10:44 PM 0
Share

It still would not compile.

avatar image Jamora · Jul 29, 2013 at 11:03 PM 0
Share

You need to read the compiler errors. You still have typos in there. Hint: two typos in access modifiers, one in a unity class and one case where you're using a wrong class to show a button.

avatar image TheSamari3397 · Jul 29, 2013 at 11:11 PM 0
Share

That doesn't help much.

avatar image Jamora · Jul 29, 2013 at 11:34 PM 0
Share

I'm sorry, but I won't give you the working script. I know for a fact if I do, you will not have learned anything. So if you're serious about making your game, you need to learn how to read compiler errors, and fix the problems.

The thing you need to do with compiler errors, is fix the topmost one, then see if it compiles. Repeat for as long as there are errors.

I'm telling you, you have three typos in your code and you're trying to call a function from a class that doesn't have it. The compiler will tell you the location of each of these.

avatar image TheSamari3397 · Jul 31, 2013 at 12:21 AM 1
Share

I figured out the problem. I was coding in C# inside of a .js I feel dumb. Thanks for the help.

Show more comments
avatar image
0

Answer by tw1st3d · Jul 31, 2013 at 12:24 AM

 using UnityEngine;
 using System.Collections;
 using System;
 
 public class pauseMenu : MonoBehavior
 {
     public GUISkin myskin;
     private Rect windowRect;
     private bool paused = false, waited = true;
      
     private void Start()
     {
         windowRect = new Rect(Screen.width/2-100, Screen.height/2-100,200,200);
     }
      
     private void waiting()
     {
         waited = true;
     }
      
     private void Update()
     {
         if (waited)
         {
             if (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P))
             {
                 if (paused)
                     paused = false;
                 else
                 {
                     paused = true;
                     waited = false;
                     Invoke("waiting",0.3f);
                 }
             }
          
             if(paused)
                 Time.timeScale =0;
             else
                 Time.timeScale =1;
         }
     }
      
      
     private void OnGUI()
     {
         if (paused)
             windowRect = GUI.Window(0,windowRect,windowFunc, "Pause Menu");
     }
      
     private void windowFunc(int id)
     {
         if(GUILayout.Button("Resume"))
             paused = false;
             
         GUILayout.BeginHorizontal();
         if(GUILayout.Button("Options"))
         {
         
         }
         if(GUILayer.Button("Main Menu"))
         {
         
         }
         
         GUILayout.EndHorizontal();
     }
 }

There was a little confusing on one of your if statements and where it ended, so take a look at lines 23-42 and make sure I got that right. Other than that, a few spelling errors, and missing brackets. This should compile.

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 TheSamari3397 · Jul 31, 2013 at 12:29 AM 0
Share

It was actually coded to be in a C# file not a java script. Thanks for the help though.

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

18 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

Related Questions

Pause menu scripting help? 1 Answer

Hold the esc button for a pause menu 1 Answer

Pause Menu Text Not Rendering 0 Answers

Pause Menu Problem 1 Answer

Bool wont change... #C 1 Answer


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