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 Dossis · Jan 12, 2012 at 03:58 PM · javascriptmouseoptionsinvert

Invert mouse control

So I'm trying to make a options menu for my game where you could change mouse controls to inverted by pressing that button. Here's the code for how I'm making the button. I would love if someone could help me and show how it's done.

So basicly: You press that Invert Mouse button and mouse gets inverted, but I don't have any clue how to do this and couldnt really find anything useful from UnityAnswers or Unity Script Reference.

 function OnGUI () 

 {

 GUI.DrawTexture(Rect(Screen.width/2-(texturewidth/2*x), Screen.height/2-(textureheight*y), texturewidth*x, textureheight*y), texture);//Draw Tex

 if(GUI.Button(Rect(Screen.width/2-(buttonwidth/2*x), Screen.height/2, buttonwidth*x, buttonheight*y),"Invert Mouse"))//Draw button

 //Invert mouse on/off code here

 if(GUI.Button(Rect(Screen.width/2-(buttonwidth/2*x), Screen.height/2+(buttonheight*2*y), buttonwidth*x, buttonheight*y),"Back to Main Menu"))//Draw button
 
         Application.LoadLevel("Main Menu");//Back to mainmenu
 
         
 
 }

The only answer I've gotten wasnt anywhere near what I need so.... Anyone, Please read my message and answer to what I need and not with what I do not need.

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 grootendorste · Feb 01, 2015 at 09:11 AM 0
Share

Hey here's a tutorial for mouse invert (Freshly made):

http://youtu.be/s-u9xV1zPaY

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by $$anonymous$$ · Feb 17, 2014 at 12:43 AM

This is an old question but I'm just responding for anyone else that may find it when looking for a way to do this. I'm new to unity so I'm not sure if this is the best way to do it but it works for my purposes. I added a public Boolean variable called invertY in the MouseLook script that is on the main camera and used it like this to invert the camera.

 if(invertY)
                     rotationY += Input.GetAxis("Mouse Y") * -sensitivityY;
                 else
                     rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

In the menu script I did the following to get a button to control the invertY variable:

 if(GameObject.FindGameObjectWithTag("MainCamera").GetComponent().invertY){
             if(GUILayout.Button("Inverted"))
                 GameObject.FindGameObjectWithTag("MainCamera").GetComponent<MouseLook>().invertY = false;
         }
         else
             if(GUILayout.Button("Normal"))
                 GameObject.FindGameObjectWithTag("MainCamera").GetComponent<MouseLook>().invertY = true;
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
avatar image
0

Answer by Berenger · Jan 12, 2012 at 04:24 PM

I don't know if you the OS mouse position is read / write, but I guess it's not. Based on that, you should draw your own cursor (http://www.unifycommunity.com/wiki/index.php?title=Custom2DPointer. The website seems to be down right now, so here is mine in c# with modifications http://dl.free.fr/n5LkCHwtg).

Then in case of inversion, just invert the mousePos

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 Dossis · Jan 12, 2012 at 06:07 PM 0
Share

$$anonymous$$aybe I didnt understand what you did mean, but that's not the one I need. I just need to know how to change mouse to inverted by pressing that button i've created.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sidescroller Bullets Follow Mouse After Being Shot 2 Answers

rotation based on mouse position 2 Answers

Having both mouse orbit and smooth follow work at the same time? 0 Answers

Detecting Mouse Scroll Wheel? 2 Answers

Input Axis Mouse ScrollWheel 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