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 Xeong-Hu · Mar 25, 2014 at 03:26 PM · mousecursordisableclicking

How can i disable the Mouse Cursor?

This is what I'm trying to actually ask.

You know when your Internet browser is buffering and your waiting for that little blue spinny logo to go away.

That's what I kind of want my game to do. Disable the clicking ability as long as this certain thing is functioning. Then when it's done functioning clicking will be available.

I'm kind of thinking about going for a true and false statement.

I searched it up, but I didn't find anything.

Can someone please help me out with this?

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

3 Replies

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

Answer by Xeong-Hu · Mar 26, 2014 at 02:42 AM

After 5 hours of struggling with this thing and eating dinner... I finally found out what my problem was.

I just had everything misplaced.

My new Code.

 private var showButton = false;
 private var pos : Vector2;
 private var hit : RaycastHit;
 var Occupied1 : GameObject;
 var Occupied2 : GameObject;
 var Occupied3 : GameObject;
 var Occupied4 : GameObject;
 var Occupied5 : GameObject;
 var Clicked = false;
 var Zone1 : float = 3.546595;
 var Zone2 : float = 1.466332;
 var Zone3 : float = -0.5914766;
 var Zone4 : float = -2.645551;
 var Zone5 : float = 3.546595;
 var jeq : MonoScript;
     var target1: Transform;
         var speed: float;
         var Summon : boolean;
         private var selectedCard : GameObject;
         var Summoning : boolean;
         
 
 
 function Update(){
 
 
     if (Input.GetMouseButtonDown (1) && showButton){
         showButton = false;
     }                                 
     
     if (Input.GetMouseButtonDown (0) && !showButton)
     {
         CheckClick ();
 
     }
             if (selectedCard.transform.position == target1.position){
         Summon = false;
         Screen.lockCursor = false;}
 
     if (Summon == true)
     
     {
     
         
         var step = speed * Time.deltaTime;
         selectedCard.transform.position = Vector3.MoveTowards(selectedCard.transform.position, target1.position, step);
        {print("I have been Summoned!");}
        Screen.lockCursor = true;
     }
 
 }
 
 function OnGUI() {
     var e = Event.current;
  
     var x = pos.x - 50;  // Calc x and y to center of button
     var y = pos.y - 10;
 
     if (showButton && GUI.Button (Rect (x,y - 95, 100, 20), "Summon")) {
     print("Summoning");
         Summon = true;
         showButton = false;
 
     }
 }
  
 function CheckClick() {
     var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, hit)) {
     Debug.Log("Card selected:"+hit.collider.name);
            if (hit.collider.tag == "Card"){
                      
                     selectedCard = hit.collider.gameObject; //Store my selection
            }
            
          pos = Camera.main.WorldToScreenPoint(hit.transform.position);
          pos.y = Screen.height - pos.y;  // convert from Screen to GUI
          showButton = true;
       
     }
     else {
        showButton = false;
        return null;
     }
 }

WHEW! FIXING THINGS YOUR SELF PUTS ME IN A HELL OF A GOOD MOOD!

Thanks for advising me guys.

I'll post it as answered incase someone else have this problem.

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 Graham-Dunnett · Mar 25, 2014 at 03:45 PM

http://docs.unity3d.com/Documentation/ScriptReference/Cursor.SetCursor.html

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 RedDevil · Mar 25, 2014 at 03:47 PM

You can just make the cursor not available during that with : Screen.showCursor = false; and then enable it whenever you want

Comment
Add comment · Show 3 · 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 Xeong-Hu · Mar 25, 2014 at 07:05 PM 0
Share

@RedDevil Alright cool I tried that before I asked but I still couldn't get this to work. and I'm looking into it but I still cant get it right.

For some odd reason when ever I click the GUI Button Summon. $$anonymous$$y mouse just flickers really quickly.

Here's what it looks like.

     var e = Event.current;
  
     var x = pos.x - 50;  // Calc x and y to center of button
     var y = pos.y - 10;
 
     if (showButton && GUI.Button (Rect (x,y - 95, 100, 20), "Summon")) {
     print("Summoning");
         Summon = true;
         showButton = false;
         Screen.showCursor = false;
     
     }
 }

Does it need to be a update function? or do I need to put a true statement in my static function?

avatar image RedDevil · Mar 25, 2014 at 07:09 PM 0
Share

i did this in the OnGUI function and i get no flickers

avatar image Xeong-Hu · Mar 25, 2014 at 08:19 PM 0
Share

It seems like I cant find a way to get around this shit..

Here's what my entire code looks like with help from a few Unity members.

 private var showButton = false;
 private var pos : Vector2;
 private var hit : RaycastHit;
 var Occupied1 : GameObject;
 var Occupied2 : GameObject;
 var Occupied3 : GameObject;
 var Occupied4 : GameObject;
 var Occupied5 : GameObject;
 var Clicked = false;
 var Zone1 : float = 3.546595;
 var Zone2 : float = 1.466332;
 var Zone3 : float = -0.5914766;
 var Zone4 : float = -2.645551;
 var Zone5 : float = 3.546595;
 var jeq : $$anonymous$$onoScript;
     var target1: Transform;
         var speed: float;
         var Summon : boolean;
         private var selectedCard : GameObject;
         var Summoned : boolean;
 
 
 function Update(){
 
 
     if (Input.Get$$anonymous$$ouseButtonDown (1) && showButton){
         showButton = false;
     }                                 
     
     if (Input.Get$$anonymous$$ouseButtonDown (0) && !showButton)
     {
         CheckClick ();
 
     }
 
     if (Summon == true)
     {
     
         if (selectedCard.transform.position == target1.position){
         Summon = false;}
         
         
         var step = speed * Time.deltaTime;
         selectedCard.transform.position = Vector3.$$anonymous$$oveTowards(selectedCard.transform.position, target1.position, step);
        {print("I have been Summoned!");}
        
     }
 
 }
 
 function OnGUI() {
     var e = Event.current;
  
     var x = pos.x - 50;  // Calc x and y to center of button
     var y = pos.y - 10;
 
     if (showButton && GUI.Button (Rect (x,y - 95, 100, 20), "Summon")) {
     print("Summoning");
         Summon = true;
         showButton = false;
         Screen.showCursor = false;
     
     }
 }
  
 function CheckClick() {
     var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, hit)) {
     Debug.Log("Card selected:"+hit.collider.name);
            if (hit.collider.tag == "Card"){
  
                     selectedCard = hit.collider.gameObject; //Store my selection
            }
            
          pos = Camera.main.WorldToScreenPoint(hit.transform.position);
          pos.y = Screen.height - pos.y;  // convert from Screen to GUI
          showButton = true;
       
     }
     else {
        showButton = false;
        return null;
     }
 }


I think it has something to do with my Check Click function.

Please anyone help me.

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

22 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

Related Questions

Disable/enable script and animation when you move your mouse cursor 1 Answer

Mouse won't freeze in center of screen 1 Answer

Mouse cursor disappears in Web Player 0 Answers

Cant unlock cursor with FPS prefab 2 Answers

Cursor lock not working after alt tab 2 Answers


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