90 lines
2.7 KiB
C#
90 lines
2.7 KiB
C#
using Assets.Scripts.UVC.Log;
|
|
using Cysharp.Threading.Tasks;
|
|
using KCA.Config;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UVC.Core;
|
|
using UVC.Data;
|
|
using UVC.Data.Core;
|
|
using UVC.Locale;
|
|
using UVC.Util;
|
|
|
|
namespace KCA
|
|
{
|
|
[DefaultExecutionOrder(100)]
|
|
public class AppMain : SingletonApp<AppMain>
|
|
{
|
|
|
|
public Action Initialized;
|
|
|
|
|
|
/// <summary>
|
|
/// 초기 화 메서드입니다.
|
|
/// Awake 메서드에서 호출되며, MonoBehaviour가 생성될 때 한 번만 실행됩니다.
|
|
/// </summary>
|
|
protected override async void Init()
|
|
{
|
|
// 플레이 모드가 아닐 경우, 초기화 로직을 실행하지 않습니다.
|
|
if (!Application.isPlaying) return;
|
|
|
|
//로깅 설정
|
|
Log4netCodeConfigurator.Setup();
|
|
|
|
await SettupConfigAsync();
|
|
SetNetworkConfig();
|
|
if (Initialized != null)
|
|
{
|
|
Initialized.Invoke();
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
//Tester.RunAllTests();
|
|
}
|
|
|
|
private async UniTask SettupConfigAsync()
|
|
{
|
|
if (AppConfig.LoadConfig())
|
|
{
|
|
Application.targetFrameRate = AppConfig.Config.TargetFrameRate;
|
|
|
|
//기본 언어 설정
|
|
bool success = LocalizationManager.Instance.LoadDefaultLocalizationData(AppConfig.Config.Language);
|
|
Debug.Log($"LocalizationManager: LoadDefaultLocalizationData success: {success}");
|
|
if (!Application.isEditor && Application.platform == RuntimePlatform.WindowsPlayer)
|
|
{
|
|
//창 설정
|
|
if (AppConfig.Config.Window != null)
|
|
{
|
|
WindowTools.Instance.Init(AppConfig.Config.Window);
|
|
}
|
|
}
|
|
|
|
Constants.API_DOMAIN = AppConfig.Config.Api;
|
|
Constants.MQTT_DOMAIN = AppConfig.Config.Mqtt.Domain;
|
|
Constants.MQTT_PORT = AppConfig.Config.Mqtt.Port;
|
|
}
|
|
|
|
//사용자 DataMask 설정 AppData에서 로드
|
|
await UserSetting.LoadFromAppData();
|
|
|
|
}
|
|
|
|
private void SetNetworkConfig()
|
|
{
|
|
DataRepository.Instance.MqttReceiver.SetDomainPort(Constants.MQTT_DOMAIN, Constants.MQTT_PORT);
|
|
DataRepository.Instance.MqttReceiver.AddTopic("controller/status");
|
|
DataRepository.Instance.MqttReceiver.AddTopic("robot/data");
|
|
|
|
//10초 후 정지
|
|
//UniTask.Delay(TimeSpan.FromSeconds(10)).ContinueWith(() =>
|
|
//{
|
|
// DataRepository.Instance.MqttReceiver.Exit();
|
|
//});
|
|
}
|
|
|
|
}
|
|
}
|