using System.Threading.Tasks; using UnityEngine; using UnityEngine.AddressableAssets; namespace DDD { [CreateAssetMenu(fileName = "GameData", menuName = "GameData/GameData")] public class GameData : ScriptSingleton { [SerializeField] private AssetReference _gameLocalizationData; [SerializeField] private AssetReference _uiData; public GameLocalizationData LocalizationData { get; private set; } public UiData UiData { get; private set; } private bool _isLoaded; public async Task LoadData() { if (_isLoaded) { return; } LocalizationData = await AssetManager.Instance.LoadAssetAsync(_gameLocalizationData); UiData = await AssetManager.Instance.LoadAssetAsync(_uiData); _isLoaded = true; } private void OnDisable() { if (_isLoaded == false) return; var assetManager = AssetManager.Instance; if (!assetManager) return; AssetManager.Instance.ReleaseAsset(_gameLocalizationData); AssetManager.Instance.ReleaseAsset(_uiData); LocalizationData = null; UiData = null; _isLoaded = false; } } }