|
@@ -27,8 +27,7 @@ namespace KairoEngine.Utilities.Statistics
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- [ListDrawerSettings(ShowPaging = false)]
|
|
|
- public List<StatisticData> data = new List<StatisticData>();
|
|
|
+ [InlineEditor(InlineEditorObjectFieldModes.Boxed)] public StatisticsList db;
|
|
|
|
|
|
void Awake()
|
|
|
{
|
|
@@ -37,6 +36,15 @@ namespace KairoEngine.Utilities.Statistics
|
|
|
Destroy(this.gameObject);
|
|
|
return;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ void Start()
|
|
|
+ {
|
|
|
+ if(db == null)
|
|
|
+ {
|
|
|
+ Debug.LogError("Statistics component is missing the StatisticsList.\nPlease configure the statistics module in the Game config file.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
LoadStatistics();
|
|
|
}
|
|
|
|
|
@@ -48,9 +56,10 @@ namespace KairoEngine.Utilities.Statistics
|
|
|
public static StatisticData GetData(string title)
|
|
|
{
|
|
|
if(instance == null) return null;
|
|
|
- for (int i = 0; i < instance.data.Count; i++)
|
|
|
+ if(instance.db == null) return null;
|
|
|
+ for (int i = 0; i < instance.db.data.Count; i++)
|
|
|
{
|
|
|
- if(instance.data[i].title == title) return instance.data[i];
|
|
|
+ if(instance.db.data[i].title == title) return instance.db.data[i];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -58,9 +67,10 @@ namespace KairoEngine.Utilities.Statistics
|
|
|
private void LoadStatistics()
|
|
|
{
|
|
|
if(instance == null) return;
|
|
|
- for (int i = 0; i < instance.data.Count; i++)
|
|
|
+ if(instance.db == null) return;
|
|
|
+ for (int i = 0; i < instance.db.data.Count; i++)
|
|
|
{
|
|
|
- StatisticData stat = instance.data[i];
|
|
|
+ StatisticData stat = instance.db.data[i];
|
|
|
if(stat.persistent == false) continue;
|
|
|
switch (stat.category)
|
|
|
{
|
|
@@ -85,9 +95,10 @@ namespace KairoEngine.Utilities.Statistics
|
|
|
private void SaveStatistics()
|
|
|
{
|
|
|
if(instance == null) return;
|
|
|
- for (int i = 0; i < instance.data.Count; i++)
|
|
|
+ if(instance.db == null) return;
|
|
|
+ for (int i = 0; i < instance.db.data.Count; i++)
|
|
|
{
|
|
|
- StatisticData stat = instance.data[i];
|
|
|
+ StatisticData stat = instance.db.data[i];
|
|
|
if(stat.persistent == false) continue;
|
|
|
switch (stat.category)
|
|
|
{
|