-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptableObjectsReferencer.cs
More file actions
48 lines (43 loc) · 1.17 KB
/
ScriptableObjectsReferencer.cs
File metadata and controls
48 lines (43 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using CerealDevelopment.LifetimeManagement;
using System.Collections.Generic;
using System.Text;
#if UNITY_EDITOR
#endif
using UnityEngine;
public class ScriptableObjectsReferencer : MonoBehaviour
{
private static ScriptableObjectsReferencer _instance;
private static bool _needsInstance = true;
public static ScriptableObjectsReferencer Instance
{
get
{
if (_needsInstance)
{
_instance = FindObjectOfType<ScriptableObjectsReferencer>();
_needsInstance = _instance == null;
if (_needsInstance)
{
var resource = Resources.Load<ScriptableObjectsReferencer>("Singletons/" + nameof(ScriptableObjectsReferencer));
_instance = Instantiate(resource);
_needsInstance = false;
}
}
return _instance;
}
}
public List<LifetimeScriptableObject> scriptableObjects = new List<LifetimeScriptableObject>();
private void Awake()
{
var builder = new StringBuilder();
builder.Append("Loading ScriptableObject references...");
for (int i = 0; i < scriptableObjects.Count; i++)
{
builder.Append("\n");
builder.Append(scriptableObjects[i].name);
scriptableObjects[i].OnLifetimeEnable();
}
Debug.Log(builder.ToString());
}
}