GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - IntoTheDev/Scriptable-Object-Loader: Load Scriptable Objects via code

BranchesTags
Open more actions menu

Latest commit

 

History

75 Commits
75 Commits

Folders and files

NameName
Last commit message
Last commit date
Runtime
Runtime
 
 
Changelog.md
Changelog.md
 
 
Changelog.md.meta
Changelog.md.meta
 
 
LICENSE
LICENSE
 
 
LICENSE.meta
LICENSE.meta
 
 
README.md
README.md
 
 
README.md.meta
README.md.meta
 
 
Runtime.meta
Runtime.meta
 
 
package.json
package.json
 
 
package.json.meta
package.json.meta
 
 

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

configdatainspectorscriptableobjectunityunity-scriptsunity2dunity3d

Resources

Readme
Activity

Stars

39 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.