Skip to content

Instantly share code, notes, and snippets.

@dmitry1100
Last active October 10, 2018 21:33
Show Gist options
  • Save dmitry1100/05653ffef3338a0cc5a91388113f6c5c to your computer and use it in GitHub Desktop.
Save dmitry1100/05653ffef3338a0cc5a91388113f6c5c to your computer and use it in GitHub Desktop.
AppSettings ScriptableObject based singleton
using UnityEngine;
namespace Fiftytwo
{
[CreateAssetMenu]
public class AppSettings : ScriptableObject
{
public static AppSettings Instance;
public App AppPrefab;
private void OnEnable()
{
if (Instance != null)
throw new UnityException(typeof(AppSettings) + " is already instantiated");
Instance = this;
}
private void OnDisable()
{
Instance = null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment