Files
chameleon/Assets/Scripts/Helper/MouseSensitivity.cs
T
adminandClaude Opus 4.8 e23fae0c50 Reorganize scripts into subfolders by responsibility
Move scripts under Assets/Scripts/ into Components, GameMode, Helper,
Network, Enum, Struct and ScriptableObject folders. Pure file moves
(plus folder .meta files); no code changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 15:02:15 +02:00

42 lines
1.3 KiB
C#

using UnityEngine;
/// Global mouse look-around sensitivity multiplier, shared by every camera
/// controller (FreeCam, FirstPerson, ThirdPersonOrbit). 1 = unchanged baseline.
/// Persisted per-machine via PlayerPrefs so the setting survives restarts.
public static class MouseSensitivity
{
public const float Default = 1f;
public const float Min = 0.1f;
public const float Max = 4f;
const string PrefKey = "Settings.MouseSensitivity";
static bool _loaded;
static float _multiplier = Default;
public static float Multiplier
{
get
{
if (!_loaded)
{
_loaded = true;
_multiplier = Mathf.Clamp(PlayerPrefs.GetFloat(PrefKey, Default), Min, Max);
}
return _multiplier;
}
set
{
float v = Mathf.Clamp(value, Min, Max);
_loaded = true;
if (Mathf.Approximately(v, _multiplier)) return;
_multiplier = v;
PlayerPrefs.SetFloat(PrefKey, v);
// Flush to disk now so the setting survives a hard kill (build), not
// only a clean quit. Settings changes are rare user actions, so the
// extra write is negligible.
PlayerPrefs.Save();
}
}
}