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 FLewis4 · Mar 06, 2013 at 07:12 AM · guiplayerwasdhowtoinstructions

I'm trying to set up an instructions menu that shows when pressing "P" on the keyboard

I was hoping someone could check over my code here, tell me if I'm going about this the wrong way. If so, what would be a better way to tackle this. I'm fairly new to coding and am trying to use the search functions, but I'm at a point where I believe I've looked at this code too much and am having issues.

Assets/Instructionsmenu.js(8,46): BCE0005: Unknown identifier: 'isPaused'.

Assets/Instructionsmenu.js(26,16): BCE0005: Unknown identifier: 'guiSkin'.

Assets/Instructionsmenu.js(29,97): BCE0005: Unknown identifier: 'nativeVerticalResolution'.

Assets/Instructionsmenu.js(29,139): BCE0005: Unknown identifier: 'nativeVerticalResolution'.

Assets/Instructionsmenu.js(32,8): BCE0005: Unknown identifier: 'isPaused'.

 function Update()
 {
  
      if(Input.GetKeyDown("Instructions") && !isPaused)
    {
       print("Paused");
       Time.timeScale = 0.0;
       isPaused = true;
    }
    else if(Input.GetKeyDown("Instructions") && isPaused)
    {
       print("Unpaused");
       Time.timeScale = 1.0;
       isPaused = false;    
    } 
 }
  
 function OnGUI ()
 {
  
     // Set up gui skin
     GUI.skin = guiSkin;
  
     // Our GUI is laid out for a 1920 x 1200 pixel display (16:10 aspect). The next line makes sure it rescales nicely to other resolutions.
     GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (Screen.height / nativeVerticalResolution, Screen.height / nativeVerticalResolution, 1)); 
  
  
     if(isPaused)
     {
       //RenderSettings.fogDensity = 1;
       if(GUI.Button (Rect((Screen.width)/2, 480, 140,70), "W to walk forward", "button2"))
       {
          print("W to walk forward");
       }
       if(GUI.Button (Rect((Screen.width)/2,560,140,70), "S to walk backwards", "button2"))
       {
          print("S to walk backward");
       }
        if(GUI.Button (Rect((Screen.width)/2,560,140,70), "D to walk to the right", "button2"))
       {
          print("D to walk to the right");
       }
        if(GUI.Button (Rect((Screen.width)/2,560,140,70), "A to walk to the left", "button2"))
       {
          print("A to walk to the left");
       }
        if(GUI.Button (Rect((Screen.width)/2,560,140,70), "Left Mouse button to Fire Rifle", "button2"))
       {
          print("Left Mouse button to Fire Rifle");
       }
       if(GUI.Button (Rect((Screen.width)/2,640,340,70), "Back to the game", "button2"))
       {
          print("Back to the game");
          Time.timeScale = 1.0;
          isPaused = false;   
       }
    } 
  
  
 }
  
  
 @script AddComponentMenu ("GUI/Pause GUI")
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Proximal-Pyro · Mar 06, 2013 at 10:55 AM

Is that you're whole script? Because if it is you need to add varibles. To add a varible type it like this(replace the things inside <> with what it stands):

var : ;

For example it looks like this:

var isPaused : boolean = false;

The = false is optional but I recomend that you type something there.

Comment
Add comment · 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

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

11 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

Related Questions

Taking a hit 3 Answers

How to make a monolgue? 1 Answer

Input trick question 3 Answers

Moving 2D Game Object on GUI Button Click 2 Answers

In Game player message - GUIText or something else? 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