mcpField
U
unity-memento-pattern

unity-memento-pattern

github.com/muharremtozanDevelopment1749 installsUpdated 22w ago
Repository

About unity-memento-pattern

unity-memento-pattern is a skill for managing state snapshots in Unity, separating data, state creation, and management through Memento, Originator, and Caretaker roles. It includes immutable snapshots, multiple save slots, and an example of hotbar state persistence.

Key features

  1. 01Immutable state snapshots
  2. 02Multiple save-slot management
  3. 03Encapsulated state structure
  4. 04Generic Memento wrapper
  5. 05Hotbar and item-state example

Use cases

  1. 01Save and restore Unity object state
  2. 02Manage multiple save or loadout slots
  3. 03Persist a list of hotbar items
  4. 04Prevent snapshots changing with later edits

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/muharremtozan/unity-agent-skills --skill unity-memento-pattern

After installing, type/unity-memento-patternin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

assets/code/
HotbarMementoExample.cs.txt
IMemento.cs.txt
LoadoutManager.cs.txt
references/
guide.md

Details

From the project README

Unity Memento Pattern

This skill provides a structured way to handle state snapshots in Unity. Inspired by Adam Myhre's implementation, it strictly separates state data (Memento), the state producer (Originator), and the state manager (Caretaker).

Core Features

  1. Immutable Snapshots: Ensures saved data cannot be corrupted by subsequent changes to the original object.
  2. Loadout Management: Built-in support for multiple save slots (Caretaker logic).
  3. Encapsulation: State structure is hidden from the resting system, exposing only what is necessary.

Core Files (Max 3)

  • IMemento.cs.txt: Base interfaces and generic Memento wrapper.
  • LoadoutManager.cs.txt: Caretaker implementation for managing list-based snapshots.
  • HotbarMementoExample.cs.txt: Practical application for UI/Item state persistence.

Usage

Refer to HotbarMementoExample.cs.txt to see how to save a list of ScriptableObjects using a copy-constructor.

Comments

Markdown supported