update
This commit is contained in:
@@ -44,12 +44,50 @@ namespace OnlyScove.Scripts
|
||||
private float CurrentPositionSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvPositionSmoothTime : positionSmoothTime;
|
||||
private float CurrentRotationSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvRotationSmoothTime : rotationSmoothTime;
|
||||
|
||||
// Public properties for UI binding
|
||||
public float Sensitivity => rotationHandler != null ? GetPrivateSensitivity() : 1f;
|
||||
public bool InvertX => rotationHandler != null ? GetPrivateInvertX() : false;
|
||||
public bool InvertY => rotationHandler != null ? GetPrivateInvertY() : false;
|
||||
|
||||
private float GetPrivateSensitivity()
|
||||
{
|
||||
var field = typeof(CameraRotationHandler).GetField("sensitivity", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return field != null ? (float)field.GetValue(rotationHandler) : 0.1f;
|
||||
}
|
||||
|
||||
private bool GetPrivateInvertX()
|
||||
{
|
||||
var field = typeof(CameraRotationHandler).GetField("invertX", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return field != null ? (bool)field.GetValue(rotationHandler) : false;
|
||||
}
|
||||
|
||||
private bool GetPrivateInvertY()
|
||||
{
|
||||
var field = typeof(CameraRotationHandler).GetField("invertY", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return field != null ? (bool)field.GetValue(rotationHandler) : false;
|
||||
}
|
||||
|
||||
public void SetFOV(float value)
|
||||
{
|
||||
tpvBaseFOV = value;
|
||||
if (_currentViewMode == CameraViewMode.ThirdPerson && !_inTransition)
|
||||
{
|
||||
_cam.fieldOfView = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (inputReader != null)
|
||||
{
|
||||
inputReader.OnToggleViewEvent += ToggleCameraView;
|
||||
}
|
||||
|
||||
if (SettingsManager.Instance != null)
|
||||
{
|
||||
SettingsManager.Instance.OnSettingsChanged += ApplyGlobalSettings;
|
||||
ApplyGlobalSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -58,6 +96,28 @@ namespace OnlyScove.Scripts
|
||||
{
|
||||
inputReader.OnToggleViewEvent -= ToggleCameraView;
|
||||
}
|
||||
|
||||
if (SettingsManager.Instance != null)
|
||||
{
|
||||
SettingsManager.Instance.OnSettingsChanged -= ApplyGlobalSettings;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyGlobalSettings()
|
||||
{
|
||||
if (SettingsManager.Instance == null || SettingsManager.Instance.Settings == null) return;
|
||||
|
||||
var settings = SettingsManager.Instance.Settings;
|
||||
|
||||
// Note: Since I cannot modify CameraRotationHandler.cs, I am using reflection
|
||||
// to fulfill the "apply these values dynamically" requirement without changing the file.
|
||||
// This is a workaround requested by the user's constraint.
|
||||
var type = typeof(CameraRotationHandler);
|
||||
type.GetField("sensitivity", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(rotationHandler, settings.sensitivity * 0.1f);
|
||||
type.GetField("invertX", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(rotationHandler, settings.invertX);
|
||||
type.GetField("invertY", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(rotationHandler, settings.invertY);
|
||||
|
||||
SetFOV(settings.fieldOfView);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -138,7 +198,7 @@ namespace OnlyScove.Scripts
|
||||
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _currentVelocity, CurrentPositionSmoothTime) + shakeManager.ShakeOffset;
|
||||
}
|
||||
|
||||
private void ToggleCameraView()
|
||||
public void ToggleCameraView()
|
||||
{
|
||||
if (_inTransition) return; // Prevent multiple toggles during transition
|
||||
|
||||
|
||||
@@ -16,16 +16,23 @@ namespace OnlyScove.Scripts
|
||||
|
||||
public void HandleSideBias(InputReader inputReader)
|
||||
{
|
||||
if (inputReader == null) return;
|
||||
float targetBias = 0f;
|
||||
|
||||
if (useSideBias)
|
||||
if (SettingsManager.Instance != null && SettingsManager.Instance.Settings != null)
|
||||
{
|
||||
float targetBias = -inputReader.MoveInput.x * horizontalBiasAmount;
|
||||
// Fixed offset based on settings
|
||||
targetBias = SettingsManager.Instance.Settings.sideBiasRight ? horizontalBiasAmount : -horizontalBiasAmount;
|
||||
}
|
||||
|
||||
if (useSideBias && inputReader != null)
|
||||
{
|
||||
// Optionally combine with movement-based bias if desired,
|
||||
// but following requirement "Toggling the camera offset between Left/Right"
|
||||
_currentSideBias = Mathf.Lerp(_currentSideBias, targetBias, biasSmoothTime * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentSideBias = 0;
|
||||
_currentSideBias = Mathf.Lerp(_currentSideBias, 0, biasSmoothTime * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user