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 CheeseScalibur · Dec 09, 2014 at 12:49 AM · if-statementsif-else

MouseLook half disabling

Hello, I need help. I've made a script and I'll show you that soon but first, I need to elaborate on what's going on. Basically, I have a GUI which appears and the player can read it but do nothing else until they press "V", once they have, they are supposed to see the GUI disappear (and they do) but when they press "V" they can't look up or down, only left or right. If they press it again, another GUI shows up and they can type in a box an answer the the question asked in the first GUI. The problem is, whenever one of the GUIs are open, vertical movement of the mouse can be achieved and whenever they are closed, only horizontal movement in enabled. Not sure what I did wrong in my script. Just so you know, I think the problems are in the if and if else statements. `using UnityEngine; using System.Collections;

public class GuiUp : MonoBehaviour {

 public bool guiUp;
 public bool guiUpBack;
 public Texture guiSkin;
 public Texture guiSkinBack;
 public string text;
 public MouseLook mouseLook;
 public MouseLook cameraMouseLook;
 public GUIStyle style;
 // Use this for initialization
 void Start () {
     mouseLook = GetComponent<MouseLook>();
     cameraMouseLook = GetComponentInChildren<MouseLook> ();
     Screen.showCursor = false;
     guiUp = true;
     Time.timeScale = 0f;
     mouseLook.enabled = false;
     cameraMouseLook.enabled = false;
 }
 void Update (){
     if(guiUp == true){
         guiUpBack = false;
     }
     if(Input.GetKeyDown(KeyCode.V) && guiUpBack == false && guiUp == true){
         guiUp = false;
         Time.timeScale = 1;
         mouseLook.enabled = true;
         cameraMouseLook.enabled = true;
     }
     else if(Input.GetKeyDown(KeyCode.V) && guiUpBack == false){
         guiUpBack = true;
         Time.timeScale = 0.0f;
         Screen.showCursor = true;
         mouseLook.enabled = false;
         cameraMouseLook.enabled = false;
     }
     else if(Input.GetKeyDown(KeyCode.V) && guiUpBack == true){
         guiUpBack = false;
         Time.timeScale = 1.0f;
         Screen.showCursor = false;
         mouseLook.enabled = true;
         cameraMouseLook.enabled = true;
     }
 }
 
 void OnGUI (){
     if(guiUp == true){
         GUI.DrawTexture(new Rect(Screen.width/8f, Screen.height/10f, 1500f, 750f), guiSkin);
     }
     if(guiUpBack == true){
         GUI.DrawTexture(new Rect(Screen.width/8f, Screen.height/10f, 1500f, 750f), guiSkinBack);
         GUI.TextArea(new Rect(Screen.width/6f, Screen.height/4f, 1000f, 100f), text, style);
     }
 }

} That's my entire code, just in case I leave something important and you guys can't help me.

Comment
Add comment · Show 1
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 CheeseScalibur · Dec 09, 2014 at 01:04 AM 0
Share

Also, if possible, could you tell me how to get my text are to work, I can't type anything in it. Thanks in advance!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unimechanic · Dec 10, 2014 at 06:04 PM

Please check the scripting tutorials:

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

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 CheeseScalibur · Dec 10, 2014 at 06:18 PM 0
Share

I've checked the tutorials, actually, I've seen them all and written notes on them, but anyway, are you able to tell me the video that would help point me in the right direction? Thanks in advance

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

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

Related Questions

Power-Ups scripting error 1 Answer

Efficient way to assign a value from another value 1 Answer

How to write a "or "statement & a if Else with or condition? 2 Answers

Why is an action in my "if" block executing in the "else" conditions? 2 Answers

if else statement ignored ?? 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