fix(): 修复重启后切换模式后相机丢失BUG,修复重启后UI绑定失效的BUG,将GameManager移动到Gameplay
This commit is contained in:
@@ -3,6 +3,7 @@ using Script.Gameplay.Input;
|
||||
using UnityEngine;
|
||||
using Core;
|
||||
using Script.Gameplay.Global;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Script.Gameplay.Player
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace Script.Gameplay.Player
|
||||
// 触发退出事件
|
||||
OnExitWatchMode?.Invoke(previousMode);
|
||||
OnEnterWatchMode?.Invoke(currentMode);
|
||||
|
||||
|
||||
SwitchWatchMode(currentMode);
|
||||
}
|
||||
}
|
||||
@@ -47,17 +48,19 @@ namespace Script.Gameplay.Player
|
||||
playerConnectController = GetComponent<PlayerConnectController>();
|
||||
|
||||
var input = inputManager.Input;
|
||||
input.Player.SwitchWatchMode.performed += ctx =>
|
||||
{
|
||||
var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % Enum.GetNames(typeof(WatchMode)).Length);
|
||||
CurrentWatchMode = modeTemp;
|
||||
};
|
||||
;
|
||||
input.Player.SwitchWatchMode.performed += RegisterInput
|
||||
;
|
||||
|
||||
ControllerLocator.Instance.Register(this);
|
||||
OnEnterWatchMode?.Invoke(currentMode);
|
||||
}
|
||||
|
||||
private void RegisterInput(InputAction.CallbackContext ctx)
|
||||
{
|
||||
var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % Enum.GetNames(typeof(WatchMode)).Length);
|
||||
CurrentWatchMode = modeTemp;
|
||||
}
|
||||
|
||||
// 实现按Tap键实现在WatchMode 3个模式切换,并通过SwitchWatchMode设置正确的相机模式
|
||||
private void SwitchWatchMode(WatchMode watchMode)
|
||||
{
|
||||
@@ -78,6 +81,7 @@ namespace Script.Gameplay.Player
|
||||
{
|
||||
playerConnectController.IsEnablePlayerConnecting = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case WatchMode.Outside:
|
||||
SetSeeLines(true);
|
||||
@@ -89,7 +93,7 @@ namespace Script.Gameplay.Player
|
||||
{
|
||||
playerInteractorController.SetPlayerInteractionEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
if (playerConnectController != null)
|
||||
{
|
||||
playerConnectController.IsEnablePlayerConnecting = true;
|
||||
@@ -113,5 +117,13 @@ namespace Script.Gameplay.Player
|
||||
|
||||
cam.cullingMask = mask;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ControllerLocator.Instance.Unregister<PlayerWatchModeController>(this);
|
||||
|
||||
var input = inputManager.Input;
|
||||
input.Player.SwitchWatchMode.performed -= RegisterInput;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user