ngui引起unity鼠标位置会不断重置为中心点
最近调试的时候,发现游戏的鼠标会自己重置回游戏的中心位置。
找了半天发现是 ngui 的UICamera 里面会设置Cursor.lockState 。。
static public KeyCode currentKey
{
get
{
return mCurrentKey;
}
set
{
if (mCurrentKey != value)
{
ControlScheme before = mLastScheme;
mCurrentKey = value;
mLastScheme = currentScheme;
if (before != mLastScheme)
{
HideTooltip();
if (mLastScheme == ControlScheme.Mouse)
{
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
Screen.lockCursor = false;
Screen.showCursor = true;
#else
//这里会重置位置
//Cursor.lockState = CursorLockMode.None;
//Cursor.visible = true;
#endif
}
#if UNITY_EDITOR
else if (mLastScheme == ControlScheme.Controller)
#else
else
#endif
{
if (current != null && current.autoHideCursor)
{
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
Screen.showCursor = false;
Screen.lockCursor = true;
#else
//这里会重置位置
//Cursor.visible = false;
//Cursor.lockState = CursorLockMode.Locked;
#endif
// Skip the next 2 frames worth of mouse movement
//mMouse[0].ignoreDelta = 2;
}
}
if (onSchemeChange != null) onSchemeChange();
}
}
}