pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/IntoTheDev/Scriptable-Object-Loader

sets.com/assets/primer-70be7debc79a8eff.css" /> GitHub - IntoTheDev/Scriptable-Object-Loader: Load Scriptable Objects via code · GitHub
Skip to content

IntoTheDev/Scriptable-Object-Loader

Repository files navigation

Scriptable Object Loader

Load Scriptable Objects via code

TODO

  • Git Package
  • Change Resources.FindObjectsOfTypeAll<ScriptableObject>(); to something else
  • Replace Resources with Asset Bundles or Addressables?

How to Install

Git Installation (Best way to get latest version)

If you have Git on your computer, you can open Package Manager indside Unity, select "Add package from Git url...", and paste link https://github.com/IntoTheDev/Scriptable-Object-Loader.git

or

Open the manifest.json file of your Unity project. Add "com.intothedev.loader": "https://github.com/IntoTheDev/Scriptable-Object-Loader.git"

Manual Installation (Version can be outdated)

Download latest package from the Release section. Import Storage.unitypackage to your Unity Project

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;
	
	public void Load()
	{
		// Do initialization here
	}
}

Now you need to create an asset.

Get Data from ScriptableObject:

using ToolBox.Loader;
using UnityEngine;

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

	private void Awake()
	{
		// Get single asset
		_health = Storage.Get<PlayerConfig>().StartHealth;
		
		// Get all assets
		var configs = Storage.GetAll<PlayerConfig>();
		
		foreach (var config in configs)
		{
			// Do something
		}
	}
}

About

Load Scriptable Objects via code

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy