Skip to content

About

Shared JSON serialization + atomic file IO + a small envelope format used by SettingsProfile and SettingsDefinition.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

Unity Essentials

This module is part of the Unity Essentials ecosystem and follows the same lightweight, editor-first approach. Unity Essentials is a lightweight, modular set of editor utilities and helpers that streamline Unity development. It focuses on clean, dependency-free tools that work well together.

All utilities are under the UnityEssentials namespace.

using UnityEssentials;

Installation

Install the Unity Essentials entry package via Unity's Package Manager, then install modules from the Tools menu.

  • Add the entry package (via Git URL)

    • Window → Package Manager
    • "+" → "Add package from git URL…"
    • Paste: https://github.com/EggyStudio/UnityEssentials.git
  • Install or update Unity Essentials packages

    • Tools → Install & Update UnityEssentials
    • Install all or select individual modules; run again anytime to update

Serializer

Quick overview: Shared JSON serialization + atomic file IO + a small envelope format used by SettingsProfile and SettingsDefinition.

This package is the shared foundation for JSON persistence across UnityEssentials. It intentionally stays small and predictable:

  • Json.NET (Newtonsoft.Json) with a shared JsonSerializerSettings (indentation + converters)
  • Atomic file writes via a temp file + replace/move
  • A shared envelope (SerializerEnvelope<T>) with metadata (Type, Name, SchemaVersion, UpdatedUtc) and a Values payload
  • Small helpers for common path and formatting tasks

Main APIs

SerializerJson

Central place for Json.NET settings and helpers.

  • SerializerJson.Serialize(value)
  • SerializerJson.Deserialize<T>(json)

SerializerEnvelope<T>

A lightweight metadata wrapper used when SettingsProfile / SettingsDefinition save to disk.

{
  "Type": "SettingsProfileBase",
  "Name": "Default",
  "SchemaVersion": 0,
  "UpdatedUtc": "2026-01-22T12:34:56.789Z",
  "Values": { }
}

SerializerJsonStore

Tiny IO layer:

  • Exists(path)
  • ReadAllText(path)
  • WriteAllTextAtomic(path, content)
  • Delete(path)

SerializerUtility

Common helpers:

  • GetPath<T>(fileName, extension: "json") → writes into a Resources folder next to the project
  • Sanitize(fileName)
  • GetLastSegment("Controls/Mouse/Sensitivity") → Sensitivity
  • GetGroupPath("Controls/Mouse/Sensitivity") → Controls/Mouse
  • LabelizePathSegment("MasterVolume") → Master Volume

Usage in other packages

Settings values: SettingsProfile

SettingsProfile<T> is a JSON-backed container that uses this serializer to persist its payload.

// Example: raw key/value store
var profile = SettingsProfile.GetOrCreate("Default");
profile.GetValue()["Audio/MasterVolume"] = 0.8f;
profile.SaveIfDirty();

Settings metadata: SettingsDefinition

SettingsDefinition is implemented as a specialized SettingsProfile<SettingsDefinitionBase>. It stores metadata (SettingsMetaData) keyed by a reference path.

var definition = SettingsDefinition.GetOrCreate("Settings");

definition
    .SetSlider("Controls/Mouse/Sensitivity", min: 0, max: 100, step: 5)
    .SetOrder(10)
    .SetTooltip("Set mouse sensitivity");

definition
    .SetOptions("Controls/Input", new[] { "Gamepad", "Keyboard" })
    .SetOrder(9)
    .SetTooltip("Select preferred input");

definition.SaveIfDirty();

Notes

  • The serializer uses Newtonsoft.Json, not UnityEngine.JsonUtility.
  • File paths are generated by SerializerUtility.GetPath<T>() (currently under a Resources folder next to the project).
  • The envelope exists to allow forward-compatible metadata (SchemaVersion, timestamps, etc.) without changing payload types.

Files in This Package

  • Runtime/SerializerJson.cs – Json.NET settings + serialize/deserialize helpers
  • Runtime/SerializerEnvelope.cs – shared envelope format
  • Runtime/SerializerJsonStore.cs – atomic read/write/delete
  • Runtime/SerializerUtility.cs – small path + label helpers

Tags

unity, json, serialization, newtonsoft, persistence, settings

About

Shared JSON serialization + atomic file IO + a small envelope format used by SettingsProfile and SettingsDefinition.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages