A memory protection system for games that prevents common cheating methods like memory scanning and value modification.
- Encryption: Values are XOR'ed with dynamic keys and bit rotation
- Tamper Detection: Runtime integrity verification with checksum validation
- Zero Friction: Replacement for standard types with implicit conversions
- Unity Integration: Fully serializable in Unity Inspector
- Optimized: Minimal overhead with lazy initialization
// Declaration
private SafeInt _score = new SafeInt(0);
private SafeFloat _health = new SafeFloat(100f);
// Use it like a normal int/float
_score = 100;
_score++;
_health -= 25.5f;
// Display in UI (implicit conversion)
textComponent.SetText($"Score: {_score}");
healthBar.fillAmount = _health / 100f;
// Serialize in Unity Inspector
[SerializeField] private SafeInt _playerLevel = new SafeInt(1);
[SerializeField] private SafeVector3 _spawnPoint = new SafeVector3(Vector3.zero);SafeIntSafeFloatSafeDoubleSafeVector2SafeVector3SafeQuaternionSafeBool
- Clone or download the repo
- Copy scripts to your Unity project
- Replace critical variables with Safe variant
- Build and test!
- Client side only - Never trust the client for server-authoritative games
- Defense in depth - Use alongside server validation and other anti-cheat measures
- Performance consideration - Suitable for critical values, not massive arrays
- Additional type support (custom structs)
- OnValueChanged events
- C++ / Unreal Engine port
- Network synchronization helpers
