Last active
October 10, 2018 21:33
-
-
Save dmitry1100/05653ffef3338a0cc5a91388113f6c5c to your computer and use it in GitHub Desktop.
AppSettings ScriptableObject based singleton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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