Skip to content

GameFrameX/com.gameframex.unity.setting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game Frame X Logo

GameFrameX Setting

License Version Unity Version Documentation

All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams


Documentation · Quick Start · QQ Group: 467608841 / 233840761


English | 简体中文 | 繁體中文 | 日本語 | 한국어

Language

English | 简体中文 | 繁體中文 | 日本語 | 한국어


Features

  • Typed key-value storage: bool, int, float, string, serializable objects (via JSON)
  • Two built-in storage backends:
    • PlayerPrefsSettingHelper (default) — uses Unity PlayerPrefs, with platform adapters for Douyin, WeChat, Kuaishou, and Alipay mini-games
    • DefaultSettingHelper — file-based binary storage at Application.persistentDataPath
  • Pluggable helper architecture — implement ISettingHelper for custom backends
  • Auto-load on start, auto-save on shutdown
  • Safe parsing with TryParse — corrupted values return defaults with a warning log instead of crashing

Architecture

SettingComponent (MonoBehaviour)
  └─ SettingManager (ISettingManager)
       └─ ISettingHelper
            ├─ PlayerPrefsSettingHelper (default)
            └─ DefaultSettingHelper

Quick Start

Installation

Choose one of the following methods:

  1. Edit your Unity project's Packages/manifest.json and add the scopedRegistries section:

    {
      "scopedRegistries": [
        {
          "name": "GameFrameX",
          "url": "https://gameframex.upm.alianblank.uk",
          "scopes": [
            "com.gameframex"
          ]
        }
      ],
      "dependencies": {
        "com.gameframex.unity.setting": "1.5.2"
      }
    }

    scopes controls which packages are resolved through this registry. Only packages whose names start with com.gameframex will be fetched from it.

  2. Add to manifest.json dependencies:

    {
       "com.gameframex.unity.setting": "https://github.com/gameframex/com.gameframex.unity.setting.git"
    }
  3. Use Package Manager in Unity with Git URL: https://github.com/gameframex/com.gameframex.unity.setting.git

  4. Clone the repository into your Unity project's Packages directory. It will be loaded automatically.

Basic Usage

// The SettingComponent is automatically available after adding to a GameObject.
// Access it via GameFramework entry or GetComponent.

SettingComponent setting = ...;

// Write settings
setting.SetBool("FullScreen", true);
setting.SetInt("ResolutionWidth", 1920);
setting.SetFloat("Volume", 0.8f);
setting.SetString("PlayerName", "PlayerOne");

// Persist to storage
setting.Save();

Read Settings

// With default fallback (returns default if key is missing or value is corrupted)
float volume = setting.GetFloat("Volume", 0.5f);

// Check existence
if (setting.HasSetting("PlayerName"))
{
    string name = setting.GetString("PlayerName");
}

Remove Settings

setting.RemoveSetting("PlayerName");
setting.RemoveAllSettings();

Switch Storage Backend

In the Inspector for SettingComponent, change Setting Helper Type Name to:

  • GameFrameX.Setting.Runtime.PlayerPrefsSettingHelper (default)
  • GameFrameX.Setting.Runtime.DefaultSettingHelper (file-based)

Or assign a custom ISettingHelper via the Custom Setting Helper field.

Supported Platforms

Backend Standard Unity Douyin WeChat Kuaishou Alipay
PlayerPrefsSettingHelper PlayerPrefs TTStorage WX SDK KS SDK Alipay SDK
DefaultSettingHelper File I/O File I/O File I/O File I/O File I/O

Mini-game storage support is isolated in platform adapter assemblies. The common GameFrameX.Setting.Runtime assembly only depends on GameFrameX.Runtime; install the matching mini-game SDK and enable its scripting define (ENABLE_DOUYIN_MINI_GAME, ENABLE_WECHAT_MINI_GAME, ENABLE_KUAISHOU_MINI_GAME, or ENABLE_ALIPAY_MINI_GAME) to compile the corresponding adapter.

API Reference

Properties

Property Type Description
Count int Number of stored settings (-1 for PlayerPrefs backend)

Methods

Method Returns Description
Load() bool Load settings from storage
Save() bool Save settings to storage
HasSetting(name) bool Check if a setting exists
RemoveSetting(name) bool Remove a single setting
RemoveAllSettings() void Clear all settings
GetAllSettingNames() string[] Get all setting key names
GetBool / SetBool bool Boolean accessors
GetInt / SetInt int Integer accessors
GetFloat / SetFloat float Float accessors (invariant culture)
GetString / SetString string String accessors
GetObject<T> / SetObject<T> T JSON-serialized object accessors

Changelog

See CHANGELOG.md for release history.

Dependencies

Package Description
com.gameframex.unity 1.1.1

Documentation & Resources

Community & Support

  • QQ Group: 467608841 / 233840761

License

Dual-licensed under MIT and Apache-2.0.

About

GameFrameX Unity Setting component for managing game settings with persistent storage and runtime configuration

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages