| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- namespace LightGlue.Unity.Runtime
- {
- /// <summary>
- /// 业务侧统一入口门面:
- /// - 默认使用 LightGlueRuntimeAdapter
- /// - 允许外部注入自定义实现(便于测试或替换)
- /// </summary>
- public static class LightGlueRuntimeFacade
- {
- public static ILightGlueRuntime Runtime { get; private set; }
- public static event Action<LightGluePositionUpdate> OnPositionUpdate;
- public static void Configure(ILightGlueRuntime runtime)
- {
- if (Runtime != null)
- Runtime.OnPositionUpdate -= ForwardOnPositionUpdate;
- Runtime = runtime;
- if (Runtime != null)
- Runtime.OnPositionUpdate += ForwardOnPositionUpdate;
- }
- public static void Ensure()
- {
- if (Runtime == null)
- {
- Runtime = new LightGlueRuntimeAdapter();
- Runtime.OnPositionUpdate += ForwardOnPositionUpdate;
- }
- Runtime.Init();
- }
- private static void ForwardOnPositionUpdate(LightGluePositionUpdate update)
- {
- OnPositionUpdate?.Invoke(update);
- }
- // 推荐新语义入口
- public static void StartRuntime()
- {
- Ensure();
- Runtime.StartRuntime();
- }
- public static void StopRuntime()
- {
- Ensure();
- Runtime.StopRuntime();
- }
- public static void ShowPluginUI()
- {
- Ensure();
- Runtime.ShowPluginUI();
- }
- public static void HidePluginUI()
- {
- Ensure();
- Runtime.HidePluginUI();
- }
- public static void SetUIRuntimeMode(LightGlueUIRuntimeMode mode)
- {
- Ensure();
- Runtime.SetUIRuntimeMode(mode);
- }
- public static void SetHardwareMode(LightGlueHardwareMode mode)
- {
- Ensure();
- Runtime.SetHardwareMode(mode);
- }
- }
- }
|