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

56 lines
2.0 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;
using UnityEngine.Serialization;
2025-10-11 15:18:09 +08:00
2026-03-10 13:48:17 +08:00
namespace AlicizaX
2025-10-11 15:18:09 +08:00
{
public class ModuleDynamicBind : MonoBehaviour
{
[FormerlySerializedAs("_resourceServiceBehaviour")] [SerializeField] private ResourceComponent resourceComponent;
[FormerlySerializedAs("_debuggerServiceBehaviour")] [SerializeField] private DebuggerComponent debuggerComponent;
[FormerlySerializedAs("_localizationServiceBehaviour")] [SerializeField] private LocalizationComponent localizationComponent;
2025-10-11 15:18:09 +08:00
private ModuleDynamicBindInfo _dynamicBindInfo;
private void OnValidate()
{
resourceComponent = GetComponentInChildren<ResourceComponent>();
debuggerComponent = GetComponentInChildren<DebuggerComponent>();
localizationComponent = GetComponentInChildren<LocalizationComponent>();
2025-10-11 15:18:09 +08:00
}
private void Awake()
{
if (Application.isEditor) return;
TextAsset text = Resources.Load<TextAsset>("ModuleDynamicBindInfo");
_dynamicBindInfo = Utility.Json.ToObject<ModuleDynamicBindInfo>(text.text);
if (resourceComponent != null)
2025-10-11 15:18:09 +08:00
{
resourceComponent.SetPlayMode(_dynamicBindInfo.ResMode);
resourceComponent.SetDecryptionServices(_dynamicBindInfo.DecryptionServices);
2025-10-11 15:18:09 +08:00
}
if (debuggerComponent != null)
2025-10-11 15:18:09 +08:00
{
debuggerComponent.SetActiveMode(_dynamicBindInfo.DebuggerActiveWindowType);
2025-10-11 15:18:09 +08:00
}
if (localizationComponent != null)
2025-10-11 15:18:09 +08:00
{
localizationComponent.SetLanguage(_dynamicBindInfo.Language);
2025-10-11 15:18:09 +08:00
}
}
}
public struct ModuleDynamicBindInfo
{
public DebuggerActiveWindowType DebuggerActiveWindowType;
public int ResMode;
public string Language;
2025-11-18 10:12:32 +08:00
public string DecryptionServices;
2025-10-11 15:18:09 +08:00
}
}