Skip to content
Ali Badpa edited this page Oct 21, 2025 · 1 revision

Asset System

RealMethod introduces a structured asset architecture that extends Unity’s ScriptableObject to provide more control over asset creation, cloning, and runtime behavior. Each asset type inherits from a shared base class called PrimitiveAsset, ensuring a unified system for all asset data in your game.

Asset Type Create in Project (Editor) Create at Runtime Clone at Runtime Edit at Runtime Typical Use Case
1.DataAsset ✅ Yes ✅ Yes ✅ Yes ✅ Yes Dynamic gameplay data, runtime state containers
2.FileAsset ✅ Yes ⚠️ Only via FileAsset.Create<T>() ❌ No ✅ Yes Save data, user profiles, persistent objects
3.UniqueAsset ✅ Yes ❌ No ❌ No ✅ Yes Global managers, single-instance settings
4.ConfigAsset ✅ Yes ❌ No ❌ No ❌ No Read-only configuration, static constants

Asset Type Overview

1. DataAsset

Flexible, runtime-safe asset for gameplay and editor use.

  • Works like a normal ScriptableObject.
  • Can be created both in the Editor and Runtime.
  • Can be cloned and edited at runtime.
  • Can reset automatically on play mode start via OnEditorPlay().
  • Ideal for runtime state data, object pools, or temporary containers.
using UnityEngine;
using RealMethod;

[CreateAssetMenu(fileName = "SCRIPTNAME", menuName = "PROJECTNAME/SCRIPTNAME", order = 1)]
public class SCRIPTNAME : DataAsset
{
    #if UNITY_EDITOR
    // public override void OnEditorPlay()
    // {
    //     base.OnEditorPlay();
    // }
    #endif
}

2. FileAsset

Controlled persistent asset — editable but cannot be duplicated or created at runtime.

  • Can be created in the Editor only.
  • Can be edited at runtime, but not created or cloned.
  • Use factory method FileAsset.Create<T>() to ensure safe creation.
  • Best for saving data, profiles, or runtime settings you want to persist but not multiply.
using UnityEngine;
using RealMethod;

[CreateAssetMenu(fileName = "SCRIPTNAME", menuName = "PROJECTNAME/SCRIPTNAME", order = 1)]
public class SCRIPTNAME : FileAsset
{
    
}

3. UniqueAsset

Singleton-type editor asset. Exists only once and cannot be cloned or created at runtime.

  • Must be created manually in the Editor.
  • Cannot be created, cloned, or replaced at runtime.
  • Can be edited at runtime (variables can change), but the asset itself always persists.
  • Perfect for global game configuration, project-wide managers, or core metadata.
using UnityEngine;
using RealMethod;

[CreateAssetMenu(fileName = "SCRIPTNAME", menuName = "PROJECTNAME/SCRIPTNAME", order = 1)]
public class SCRIPTNAME : UniqueAsset
{
    
}

4. ConfigAsset

Immutable, read-only asset used purely as configuration data.

  • Created in the Editor only.
  • Cannot be created, cloned, or modified at runtime.
  • Validation automatically ensures all fields are private and all properties are read-only.
  • Ideal for read-only configuration, balance data, or localization constants.
using UnityEngine;
using RealMethod;

[CreateAssetMenu(fileName = "SCRIPTNAME", menuName = "PROJECTNAME/SCRIPTNAME", order = 1)]
public class SCRIPTNAME : ConfigAsset
{
    
}

RootA ChildA SubChildA RootB ChildB

Clone this wiki locally