com.alicizax.unity.framework/Runtime/ABase/ModuleDynamicBind.cs

53 lines
1.7 KiB
C#
Raw Normal View History

2025-10-11 15:18:09 +08:00
using System;
using AlicizaX.Debugger.Runtime;
using AlicizaX.Localization.Runtime;
using AlicizaX.Resource.Runtime;
using UnityEngine;
namespace AlicizaX.Framework.Runtime.ABase
{
public class ModuleDynamicBind : MonoBehaviour
{
[SerializeField] private ResourceComponent _resourceComponent;
[SerializeField] private DebuggerComponent _debuggerComponent;
[SerializeField] private LocalizationComponent _localizationComponent;
private ModuleDynamicBindInfo _dynamicBindInfo;
private void OnValidate()
{
_resourceComponent = GetComponentInChildren<ResourceComponent>();
_debuggerComponent = GetComponentInChildren<DebuggerComponent>();
_localizationComponent = GetComponentInChildren<LocalizationComponent>();
}
private void Awake()
{
if (Application.isEditor) return;
TextAsset text = Resources.Load<TextAsset>("ModuleDynamicBindInfo");
_dynamicBindInfo = Utility.Json.ToObject<ModuleDynamicBindInfo>(text.text);
if (_resourceComponent != null)
{
_resourceComponent.SetPlayMode(_dynamicBindInfo.ResMode);
}
if (_debuggerComponent != null)
{
_debuggerComponent.SetActiveMode(_dynamicBindInfo.DebuggerActiveWindowType);
}
if (_localizationComponent != null)
{
_localizationComponent.SetLanguage(_dynamicBindInfo.Language);
}
}
}
public struct ModuleDynamicBindInfo
{
public DebuggerActiveWindowType DebuggerActiveWindowType;
public int ResMode;
public string Language;
}
}