Skip to content

IntoTheDev/Scriptable-Object-Loader

Repository files navigation

Scriptable Object Loader

Load Scriptable Objects via code

Usage

Creating ScriptableObject:

Your ScriptableObject must implement ILoadable interface.

using ToolBox.Loader;
using UnityEngine;

[CreateAssetMenu(menuName = "Game/Configs/Player")]
public class PlayerConfig : ScriptableObject, ILoadable
{
	[SerializeField] private float _startHealth = 100f;

	public float StartHealth => _startHealth;
}

Now you need to create an asset.

Get Data from ScriptableObject:

using ToolBox.Loader;

public class Player : MonoBehaviour
{
	private float _health = 0f;

	private void Awake()
	{
		_health = Storage.Get<PlayerConfig>().StartHealth;
	}
}

TODO

  • Replace Resources with Asset Bundles or Addressables
  • Git Package