-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameManagerSettingsProfile.cs
129 lines (112 loc) · 3.79 KB
/
GameManagerSettingsProfile.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using CHARK.GameManagement.Utilities;
using UnityEngine;
namespace CHARK.GameManagement.Settings
{
[CreateAssetMenu(
fileName = CreateAssetMenuConstants.BaseFileName + nameof(GameManagerSettingsProfile),
menuName = CreateAssetMenuConstants.BaseMenuName + "/Game Manager Settings Profile",
order = CreateAssetMenuConstants.BaseOrder
)]
internal sealed class GameManagerSettingsProfile : ScriptableObject, IGameManagerSettingsProfile
{
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("General", Expanded = true)]
#else
[Header("General")]
#endif
[Tooltip(
"Is this settings profile the active profile?"
)]
[SerializeField]
private bool isActiveProfile;
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Instantiation", Expanded = true)]
#else
[Header("Instantiation")]
#endif
[Tooltip(
"Should " + nameof(GameManager) + " automatically instantiate?"
)]
[SerializeField]
private bool isInstantiateAutomatically;
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Instantiation", Expanded = true)]
[Sirenix.OdinInspector.AssetsOnly]
[Sirenix.OdinInspector.Required]
[Sirenix.OdinInspector.ShowIf(nameof(isInstantiateAutomatically))]
#endif
[Tooltip(
""
+ "Prefab to instantiate when " + nameof(isInstantiateAutomatically)
+ " is set to true"
)]
[SerializeField]
private GameManager gameManagerPrefab;
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Instantiation", Expanded = true)]
[Sirenix.OdinInspector.ShowIf(nameof(isInstantiateAutomatically))]
#endif
[Tooltip(
""
+ "When to instantiate " + nameof(gameManagerPrefab)
+ " on game start using " + nameof(RuntimeInitializeOnLoadMethodAttribute)
)]
[SerializeField]
private InstantiationMode instantiationMode = InstantiationMode.BeforeSceneLoad;
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Features", Expanded = true)]
#else
[Header("Features")]
#endif
[Tooltip("Should " + nameof(GameManager) + " persist between scene loads?")]
[SerializeField]
private bool isDontDestroyOnLoad = true;
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Features", Expanded = true)]
#endif
[Tooltip("Should verbose " + nameof(GameManager) + " logging be enabled?")]
[SerializeField]
private bool isVerboseLogging;
public string Name
{
get
{
if (string.IsNullOrWhiteSpace(name))
{
return GetType().Name;
}
return name;
}
}
internal bool IsActiveProfile
{
get => isActiveProfile;
set
{
var isActiveOld = isActiveProfile;
var isActiveNew = value;
#if UNITY_EDITOR
if (isActiveOld != isActiveNew)
{
UnityEditor.EditorUtility.SetDirty(this);
}
#endif
isActiveProfile = value;
}
}
public bool IsInstantiateAutomatically => isInstantiateAutomatically;
public InstantiationMode InstantiationMode => instantiationMode;
public bool IsDontDestroyOnLoad => isDontDestroyOnLoad;
public bool IsVerboseLogging => isVerboseLogging;
public bool TryGetGameManagerPrefab(out GameManager prefab)
{
if (gameManagerPrefab)
{
prefab = gameManagerPrefab;
return true;
}
prefab = default;
return true;
}
}
}