[英]c# Cannot implicitly convert type 'bool' to 'UnityEngine.CursorLockMode'
I have tried to make a menu system in unity using c# 我试图使用c#统一制作菜单系统
the script I use to hide and show keeps coming back with this error: 我用来隐藏和显示的脚本不断出现此错误:
Cannot implicitly convert type 'bool' to 'UnityEngine.CursorLockMode'
无法将类型'bool'隐式转换为'UnityEngine.CursorLockMode'
here is the code 这是代码
using UnityEngine;
using System.Collections;
public class Pause : MonoBehaviour {
public GameObject Canvas;
public GameObject Camera;
bool Paused = false;
void Start(){
Canvas.gameObject.SetActive (false);
}
void Update () {
if (Input.GetKey ("escape")) {
if(Paused == true){
Time.timeScale = 1.0f;
Canvas.gameObject.SetActive (false);
Cursor.visible = false;
Cursor.lockState = true;
Paused = false;
} else {
Time.timeScale = 0.0f;
Canvas.gameObject.SetActive (true);
Cursor.visible = true;
Cursor.lockState = false;
Paused = true;
}
}
}
public void Resume(){
Time.timeScale = 1.0f;
Canvas.gameObject.SetActive (false);
Cursor.visible = false;
Cursor.lockState = true;
}
}
Cursor.lockState
isn't a boolean, is of type CursorLockMode
. Cursor.lockState
不是布尔值,类型为CursorLockMode
。
You need to set it to CursorLockMode.Locked
or possibly CursorLockMode.Confined
(depending on what you want to do) and CursorLockMode.None
您需要将其设置为
CursorLockMode.Locked
或可能CursorLockMode.Confined
(取决于你想要做什么)和CursorLockMode.None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.