123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- namespace KairoEngine.Utilities.Statistics
- {
- public enum StatisticChangeIntegerTrigger
- {
- OnStart,
- OnDisable,
- OnDestroy
- }
- [HideMonoScript]
- public class StatisticChangeInteger : MonoBehaviour
- {
- [HorizontalGroup()] public string statisticName = "";
- [HorizontalGroup(80), ReadOnly, HideLabel] public string value;
- public StatisticChangeIntegerTrigger trigger;
- public int number;
- void Start()
- {
- if(Statistics.instance == null) Debug.LogError("Statistics not loaded yet");
- if(trigger == StatisticChangeIntegerTrigger.OnStart) ChangeInteger();
- }
- void OnDisable()
- {
- if(trigger == StatisticChangeIntegerTrigger.OnDisable) ChangeInteger();
- }
- void OnDestroy()
- {
- if(trigger == StatisticChangeIntegerTrigger.OnDestroy) ChangeInteger();
- }
- void Update()
- {
- value = Statistics.GetData(statisticName).GetInteger().ToString();
- }
- public void ChangeInteger()
- {
- Statistics.GetData(statisticName).AddInteger(number);
- }
- }
- }
|