This commit is contained in:
2025-10-09 11:54:18 +08:00
parent 2aeeaf7659
commit 34f977047d
33 changed files with 181 additions and 152 deletions

View File

@@ -4,6 +4,7 @@ using UnityEngine;
public class GameSystem : Singleton<GameSystem>
{
public NetWorkThirdCharacterController localPlayer;
public void Init()
{
UIManager.Inst.Init();
@@ -11,4 +12,11 @@ public class GameSystem : Singleton<GameSystem>
GraphicsManager.Inst.Init();
AudioManager.Inst.Init();
}
public void UpdateCursorState(bool value)
{
if (localPlayer != null)
{
localPlayer.UpdateCursorState(value);
}
}
}

View File

@@ -29,6 +29,7 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
private Vector3 verticalVelocity;
private Vector2 moveInput;
private bool isGrounded;
[SerializeField]
private bool isCursorLocked = true;
void Awake()
@@ -45,6 +46,12 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
RotateModel();
UpdateAnimator();
}
public void UpdateCursorState(bool value)
{
if (!isLocalPlayer) return;
isCursorLocked = value;
UpdateCursorState();
}
private void UpdateCursorState()
{
if (!isLocalPlayer) return;
@@ -119,8 +126,6 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
if (!isLocalPlayer) return;
if (context.performed)
{
isCursorLocked = !isCursorLocked;
UpdateCursorState();
if (UIManager.Inst.CheckShow(nameof(SettingsWindow)))
{
UIManager.Inst.HideWindow(nameof(SettingsWindow));
@@ -195,6 +200,7 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
public override void OnStartLocalPlayer()
{
Debug.Log("OnStartLocalPlayer");
GameSystem.Inst.localPlayer = this;
vCam.Priority = 15;
UpdateCursorState();
}

View File

@@ -48,6 +48,12 @@ public class ThirdCharacterController : MonoBehaviour
RotateModel();
UpdateAnimator();
}
public void UpdateCursorState(bool value)
{
if (!isLocalPlayer) return;
isCursorLocked = value;
UpdateCursorState();
}
private void UpdateCursorState()
{
if (!isLocalPlayer) return;
@@ -113,8 +119,6 @@ public class ThirdCharacterController : MonoBehaviour
if (!isLocalPlayer) return;
if (context.performed)
{
isCursorLocked = !isCursorLocked;
UpdateCursorState();
if (UIManager.Inst.CheckShow(nameof(SettingsWindow)))
{
UIManager.Inst.HideWindow(nameof(SettingsWindow));

View File

@@ -79,7 +79,7 @@ public class GraphicsSetting
public float renderScale = 1.0f;
public bool isCustom = false;
public int resolutionIndex = 0;
public int resolutionIndex = Screen.resolutions.Length - 1;
public bool fullscreen = true;
public bool borderless = false;
public int displayIndex = 0;

View File

@@ -37,8 +37,12 @@ public class SettingsWindow : UIBaseWindow
}
SwitchPanel(generalPanel);
base.OnShow();
GameSystem.Inst.UpdateCursorState(false);
}
protected override void OnHide()
{
GameSystem.Inst.UpdateCursorState(true);
}
private void SwitchPanel(UIBasePanel newPanel)
{
if (currentPanel != null)