Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CreateAssetMenu]
- public class ManagerScriptableObject : ScriptableObject
- {
- //variable will hold the instance value so we don't look for it everytime we need to access it
- //access the Instance only via the Current Property
- static ManagerScriptableObject _current;
- public static ManagerScriptableObject Current
- {
- get
- {
- //check if null or if the application is not playing
- //because we might've adedd an override so the current version could be invalid
- if (_current == null || !Application.isPlaying)
- _current = GetCurrent();
- return _current;
- }
- }
- static ManagerScriptableObject GetCurrent()
- {
- var list = Resources.LoadAll<ManagerScriptableObject>("");
- if (list.Length == 0) return null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i].name.ToLower().Contains("override"))
- return list[i];
- }
- return list.First();
- }
- //Is there a Current instance ?
- public static bool AssetAvaliable { get { return Current != null; } }
- }
Add Comment
Please, Sign In to add comment