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 reddy · Dec 20, 2010 at 08:44 PM · cursorlock

cursor problem??

Hi everyone I'm have a little trouble with the Lockcursor script. The problem is i just want my cursor to be visible & don't disappear when i clicked on the gui of the pausemenu & i want it to be disappear when i pressed escape or continue in pause menu. Pls help me. ThanX in advance.

this is the script attached

static var canLock : boolean = true;

function Start () { // Start out in paused mode in web player

// if (Application.platform == RuntimePlatform.OSXWebPlayer || // Application.platform == RuntimePlatform.WindowsWebPlayer) // { // SetPause(true); canLock=true; // } // else // { // SetPause(true); // Screen.lockCursor = true; // } }

function OnApplicationQuit () { Time.timeScale = 1; }

function SetPause (pause : boolean) { var player = GameObject.FindWithTag("Player");

if(canLock){ Input.ResetInputAxes(); var gos : Object[] = FindObjectsOfType(GameObject); for (var go : GameObject in gos) go.SendMessage("DidPause", pause, SendMessageOptions.DontRequireReceiver);

 transform.position = Vector3.zero;

 if (pause)
 {
     Time.timeScale = 0;
     transform.position = Vector3 (.5, .5, 0);
     guiText.anchor = TextAnchor.MiddleCenter;
     player.BroadcastMessage("Freeze", SendMessageOptions.DontRequireReceiver);

 }
 else
 {
     guiText.anchor = TextAnchor.UpperCenter;
     transform.position = Vector3(.5, .1, 0);
     Time.timeScale = 1;
     player.BroadcastMessage("UnFreeze", SendMessageOptions.DontRequireReceiver);

 }

}

}

//function DidPause (pause : boolean){
// if (canLock){ // if (pause){ // // Show the button again // guiText.enabled = false; // guiText.text = "Click to start playing"; // } else { // Disable the button // guiText.enabled = false; // guiText.text = "Escape to show the cursor"; // } // } else { // guiText.enabled = false; // } function OnMouseDown () { // Lock the cursor if(canLock) Screen.lockCursor = true; }

private var wasLocked = false;

function Update () { if (Input.GetMouseButton(0) && canLock) Screen.lockCursor = true;

if (Input.GetButtonDown("escape") && canLock) Screen.lockCursor = true;

if (Input.GetButton("escape")) Screen.lockCursor = false;

// Did we lose cursor locking? // eg. because the user pressed escape // or because he switched to another application // or because some script set Screen.lockCursor = false; if (!Screen.lockCursor && wasLocked) { wasLocked = false; SetPause(true); } // Did we gain cursor locking? else if (Screen.lockCursor && !wasLocked) { wasLocked = true; SetPause(false); }

} function Unlock () { Screen.lockCursor = false; canLock=false; } function Lock () { Screen.lockCursor = true; canLock=true; }

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

0 Replies

· Add your reply
  • Sort: 

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

1 Person is following this question.

avatar image

Related Questions

Cursor Locks/Hides but Will Not Reappear? 1 Answer

Cursor lock not working after alt tab 2 Answers

One Last GUI Question 1 Answer

Standalone problem with cursor 2 Answers

Locking cursor Issue - Flash 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