Skip to content

IntoTheDev/Scriptable-Object-Loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Scriptable Object Loader

Load Scriptable Objects via code

Usage

Creating ScriptableObject:

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

		public float StartHealth => _startHealth;
	}

Now you need to create an asset and put it in Resources folder

Get Data from ScriptableObject:

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

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