Functional requirements:
When the menu pops up, the camera is locked and the mouse is displayed; when the menu is closed, the mouse is hidden;
Video tutorial (over the wall required) :
https://www.youtube.com/watch?v=nMgk72JSxz8& list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ& index=27
The code is as follows:
using UnityStandardAssets.Characters.FirstPerson; // The header file needs to be added camera first person
If (Input. GetKeyDown (KeyCode. B))
{
PauseMenu. SetActive (! PauseMenu.activeSelf);
}// press B to switch the backpack
If (pausemenu.activeself)
{
cursor.visible = true;
if (cursorlockstate == CursorLockMode.Locked)
{
curb.lockstate = CursorLockMode.None; .
}
aaaa GetComponent< RigidbodyFirstPersonController> ().mouseLook.XSensitivity = 0;
aaaa. GetComponent< RigidbodyFirstPersonController> ().mouseLook.YSensitivity = 0;
}// when the backpack is opened, the mouse will display, do not lock, the camera will lock; RigidbodyFirstPersonController script component is the camera,
The motion of the camera can be controlled by controlling XSensitivity and YSensitivity
If (! Pausemenu.activeself)
{
cursor.visible = false;
Cursor. LockState = CursorLockMode. Locked;
aaaa. GetComponent< RigidbodyFirstPersonController> ().mouseLook.XSensitivity = 2;
aaaa. GetComponent< RigidbodyFirstPersonController> ().mouseLook.YSensitivity = 2;
}// when the backpack is closed, the mouse does not show, lock, camera unlock
When the menu pops up, the camera is locked and the mouse is displayed; when the menu is closed, the mouse is hidden;
Video tutorial (over the wall required) :
https://www.youtube.com/watch?v=nMgk72JSxz8& list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ& index=27
The code is as follows:
using UnityStandardAssets.Characters.FirstPerson; // The header file needs to be added camera first person
If (Input. GetKeyDown (KeyCode. B))
{
PauseMenu. SetActive (! PauseMenu.activeSelf);
}// press B to switch the backpack
If (pausemenu.activeself)
{
cursor.visible = true;
if (cursorlockstate == CursorLockMode.Locked)
{
curb.lockstate = CursorLockMode.None; .
}
aaaa GetComponent< RigidbodyFirstPersonController> ().mouseLook.XSensitivity = 0;
aaaa. GetComponent< RigidbodyFirstPersonController> ().mouseLook.YSensitivity = 0;
}// when the backpack is opened, the mouse will display, do not lock, the camera will lock; RigidbodyFirstPersonController script component is the camera,
The motion of the camera can be controlled by controlling XSensitivity and YSensitivity
If (! Pausemenu.activeself)
{
cursor.visible = false;
Cursor. LockState = CursorLockMode. Locked;
aaaa. GetComponent< RigidbodyFirstPersonController> ().mouseLook.XSensitivity = 2;
aaaa. GetComponent< RigidbodyFirstPersonController> ().mouseLook.YSensitivity = 2;
}// when the backpack is closed, the mouse does not show, lock, camera unlock
Read More:
- Global lock, table lock and row lock in MySQL
- When linux installs rpm, it prompts: can’t create transaction lock on /var/lib/rpm/.rpm.lock error
- Lock mechanism in Oracle
- Ansible Failed – apt lock
- Lock wait timeout exceeded — transaction and index
- DB2 encountered the problem of sqlcode = 911 lock table when updating record update
- Waiting for another pilot command to release the startup lock
- Java uses lock to realize multithread sequential alternate execution mode 2
- InnoDB: Unable to lock ibdata1, error: 35
- MySQL error 1205 (HY000): lock wait timeout exceeded; try restarting transaction
- Centos 7 | mariadb/mysql | [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
- Fatal: unable to create ‘project_ path/.git/ index.lock ‘: File exists.
- mysqldump: Got error: 1016: Can’t open file: ‘./xxx.frm’ (errno: 24) when using LOCK TABLES
- Implementation of multithread sequential alternate execution by using lock in Java
- Forced shutdown of VMware wrokstation error (failed to get exclusive lock on the configuration file —)
- could not be opened to write the process output: fopen(/tmp\sf_proc_00.out.lock)
- [338] MySQL error: error 1205: lock wait timeout exceeded solution
- VMware failed to lock memory file. Error restoring virtual machine state from file
- Permission denied error: unable to index file .vs/Trip2015/v15/Server/sqlite3/db.lock fatal: adding
- Notes on unity project_ Unity webplayer failed to update unity web player