Skip to content

A powerful Unity package that enhances ScriptableObjects with runtime data management, editor debugging capabilities, and intuitive data separation between editor and runtime environments.

License

Notifications You must be signed in to change notification settings

thisaislan/scriptables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Scriptables

A powerful Unity package that enhances ScriptableObjects with runtime data management, editor debugging capabilities, and intuitive data separation between editor and runtime environments.

Unity Download Link License MIT License MIT


Table of Contents


โœจ Features

  • Dual Data System: Separate editor data from runtime data with automatic reset functionality
  • Runtime ScriptableObjects: Data that automatically resets when exiting play mode
  • Settings ScriptableObjects: Preserve editor data while allowing runtime modifications
  • Reactive ScriptableObjects: Preserve editor data while allowing other classes to add observer to value changes
  • Advanced Editor Integration: Custom inspector with real-time data visualization
  • Type-Safe Data Management: Generic implementation supporting any serializable data type
  • Reflection-Based UI: Automatically generates editor UI for the data structures (Editor mode)
  • Reset Management: Automatic data cleanup when entering/exiting play mode
  • Scriptable Panel: Panel to help organize all scriptableObjects in the project (Tools/Scriptable/Panel)

๐Ÿ—๏ธ Overview

The package follows a clean ScriptableObject architecture by dividing them into three specialized types:

โš™๏ธ Scriptable Settings

  • Fixed data configured to be used when the game runs
  • Can be updated via remote config, repositories, or any external means
  • Persistent data that maintains editor-configured values
  • Ideal for game configuration, constants, and setup parameters

๐Ÿ”„ Scriptable Runtime

  • Temporary data shared across different systems in the project
  • Volatile data that resets automatically
  • Perfect for game state, temporary variables, and system communication
  • No persistence - reset to defaults on every run

๐Ÿ”ฅScriptable Reactive

  • Observable data that notifies listeners automatically when values change
  • Editor/Runtime separation maintains different values for edit mode vs. play mode
  • Event-driven architecture allows decoupled communication between systems
  • Automatic persistence preserves editor-configured values while allowing runtime modifications

๐Ÿš€ Quick Start


Creating Scriptable Settings

[CreateAssetMenu(fileName = "BarScriptableSettings", menuName = "Bar/Settings")]
public class BarScriptableSettings : ScriptableSettings<BarScriptableSettings.BarData>
{
    [Serializable]
    public class BarData : Data
    {
        public string Foo;
    }
}

When a new instance is created of these ScriptableObjects in the Inspector, they appear with a clean, organized interface:




And in play mode:




The editor provides:

Clear separation between Settings and Runtime data

Intuitive interface for configuring default values

Visual indicators for data type and purpose

Method to initialize data when necessary

Method to print data (Editor only)

Creating Scriptable Runtime

[CreateAssetMenu(fileName = "FooScriptableRuntime", menuName = "Foo/Runtime")]
public class FooScriptableRuntime : ScriptableRuntime<FooScriptableRuntime.FooData>
{
    [Serializable]
    public class FooData : Data
    {
        public int Bar;
    }
}

Instance:




Play mode:




As ScriptableSettings the runtime data can be changed freely during gameplay without any persistence concerns. The system automatically handles:

Automatic Reset: Runtime data resets to default values on every run in the Unity Editor

Zero Persistence: Changes made during runtime are never saved automatically

Isolated Modifications: Runtime changes don't affect the original editor-configured values

Clean State: Every play session starts with fresh, default data

Runtime features include:

Real-time data modification capabilities

Visual feedback for data changes

Reset functionality for testing

Clean display of current runtime values

Method to reset data when necessary

Method to print data (Editor only)

Creating Scriptable Reactive

Scriptable Reactives are observable data containers that automatically notify listeners when their values change, enabling reactive programming patterns throughout on the project.

It is possible to create Scriptable Reactives using the asset menu by right-clicking and selecting: Create > Scriptables > Reactives


The following pre-made types are available:

  • BooleanScriptableReactive
  • ColorScriptableReactive
  • DoubleScriptableReactive
  • FloatScriptableReactive
  • GameObjectScriptableReactive
  • IntScriptableReactive
  • NoParametersScriptableReactive
  • QuaternionScriptableReactive
  • StringScriptableReactive
  • TransformScriptableReactive
  • Vector2ScriptableReactive
  • Vector3ScriptableReactive

When a instances of these ScriptableObjects is created in the Inspector (Vector2 type):




In play mode:




It is possible to extend the ScriptableReactive class to create custom reactive types:

[CreateAssetMenu(fileName = "FooBarScriptableReactive", menuName = "FooBar/Reactive")]
public class FooBarScriptableReactive : ScriptableReactive<FooBarScriptableReactive>
{
    // Methods here if needed
}

Note: Not all types are serializable by default or will be visible in the editor. Ensure the custom type is marked as [System.Serializable] if it's a custom class.


Like ScriptableSettings, Scriptable Reactives handle runtime data intelligently:

Automatic Reset: Runtime values reset to editor-configured defaults on every play session

Zero Persistence: Runtime modifications are never automatically saved

Isolated Modifications: Editor values remain untouched during gameplay

Clean State: Each play session starts with fresh, predictable data

Features include:

Method to reset data (When possible)

Method to print data (Editor only)

Methods to ensure observability of the data

๐Ÿ“ฆ Install

  1. Copying git url https://github.com/thisaislan/scriptables.git

  2. Click on Window/Package Manager in Unity Editor

  3. Click on add package button Add package button

  4. Select Add package from git URL...

  5. Past the url

  6. Press Enter or clink on the Add button

  7. Enjoy ๐Ÿ˜†


๐Ÿค Support

Please submit any queries, bugs or issues, to the Issues page on this repository. All feedback is appreciated as it not just helps myself find problems I didn't otherwise see, but also helps improve the project.


๐Ÿ’– Thanks

My friends and family, and you for having come here!


๐Ÿ“„ License

Copyright (c) 2024-present Aislan Tavares (@thisaislan) and Contributors. Scriptables is free and open-source software licensed under the MIT License.









Enjoy! โ™ฅ๏ธ


About

A powerful Unity package that enhances ScriptableObjects with runtime data management, editor debugging capabilities, and intuitive data separation between editor and runtime environments.

Topics

Resources

License

Stars

Watchers

Forks

Languages