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 Sveyh · Mar 28, 2014 at 11:56 PM · guigui-buttonmain camerapasswordfield

C# pausing the game during GUI keypad

Hello, I got this keypad script, which I wrote myself, and I was wondering if its possible to pause the movement of the camera while the GUI is up, and if I click on the GUI "Ok" button, the movement comes back as right now when Im trying to click the GUI buttons on my keypad. If you have played Splinter Cell Chaos Theory, like those keypads.

Keypad Code:

 public class Keypad : MonoBehaviour 
 {
     public string password = "1234";
     private string pwd = "";
     private bool Frodo;
     public AudioClip Ok;
     public GameObject objectToMove;
     // Use this for initialization
     void Start () 
     {
         Frodo = false;
     }
     void Update()
     {
         if (Input.anyKeyDown) { return; }
     }
     void OnTriggerEnter()
     {  
             Frodo = true;    
     }
     void OnGUI()
     {
         GUI.color = Color.blue;
         if (Frodo == true)
         {
             GUI.Box(new Rect(275, 50, 350, 250), "");//bakgrundsfält till knapparna
 
             pwd = GUI.PasswordField(new Rect(325, 60, 200, 50), pwd, "*"[0], 4);//4 siffrigt lösenord fält.
 
             if(GUI.Button(new Rect(350, 125, 50, 50), "1"))
             {
                 pwd += "1";
                 audio.Play();
             }
             if(GUI.Button(new Rect(400, 125, 50, 50), "2"))
             {
                 pwd += "2";
                 audio.Play();
             }
             if(GUI.Button(new Rect(450, 125, 50, 50), "3"))
             {
                 pwd += "3";
                 audio.Play();
             }
             if(GUI.Button(new Rect(350, 175, 50, 50), "4"))
             {
                 pwd += "4";
                 audio.Play();
             }
             if(GUI.Button(new Rect(400, 175, 50, 50), "5"))
             {
                 pwd += "5";
                 audio.Play();
             }
             if(GUI.Button(new Rect(450, 175, 50, 50), "6"))
             {
                 pwd += "6";
                 audio.Play();
             }
             if(GUI.Button(new Rect(350, 225, 50, 50), "7"))
             {
                 pwd += "7";
                 audio.Play();
             }
             if(GUI.Button(new Rect(400, 225, 50, 50), "8"))
             {
                 pwd += "8";
                 audio.Play();
             }
             if(GUI.Button(new Rect(450, 225, 50, 50), "9"))
             {
                 pwd += "9";
                 audio.Play();
             }
             if(GUI.Button(new Rect(500, 125, 65, 45), "Clear"))//rensar passwordfältet
             {
                 audio.Play();
                 pwd = "";
             }
             if(GUI.Button(new Rect(500, 190, 85, 85), "Ok"))//Ok knapp som man klickar på efter koden
             {
                 audio.Play();
                 if (pwd == password) 
                 {
                     audio.PlayOneShot(Ok);
                     objectToMove.transform.position = new Vector3(-75, 6, -18);
 
                 }
             }
         }
     }
     void OnTriggerExit()
     {
         Frodo = false;
     }
 }

Thanks in advance.

Comment
Add comment · Show 4
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 getyour411 · Mar 29, 2014 at 12:17 AM 0
Share

Is the movement of the camera controlled by something like $$anonymous$$ouseLook? If so, get references to the $$anonymous$$ouseLook component and set them to disabled while GUI is up.

avatar image Sveyh · Mar 29, 2014 at 12:37 AM 0
Share

Like Getcomponent > disable that script on Trigger enter > when click Ok GUI button > enable that script

avatar image getyour411 · Mar 29, 2014 at 12:45 AM 0
Share

Yep that's it

avatar image Sveyh · Mar 29, 2014 at 12:57 AM 0
Share

But I've called my mouse script here Smooth$$anonymous$$ouseLook mouselook = GetComponent(); and how do I disable it?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by getyour411 · Mar 29, 2014 at 01:03 AM

().enabled and ().disabled

See the docs and plenty of other resources for more info

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 Lo0NuhtiK · Mar 29, 2014 at 01:05 AM 0
Share

http://unity3d.com/learn/tutorials/modules/beginner/scripting/enabling-disabling-components

http://unity3d.com/learn/tutorials/modules/beginner/scripting

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

21 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 avatar image avatar image avatar image

Related Questions

C# GUI keypad 2 Answers

GUI.PasswordField "•" makes "?" 1 Answer

Close my GUI button by repressing the same Hot-key. 3 Answers

help with errors 2 Answers

How to toggle the color of a button? 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