Files
Simulation/Assets/WorkSpace/LH/Web/WebReceiver.cs
2025-07-14 17:50:13 +09:00

50 lines
1.4 KiB
C#

using Newtonsoft.Json;
using UnityEngine;
using System;
namespace Octopus.Simulator.Networks
{
public class WebReceiver : MonoBehaviour
{
public SimulatorConfig config;
public event Action onParameterRecived;
public event Action<string> onMqttConfigReceived;
public event Action<string> onWebConfigReceived;
public void Start()
{
onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo;
onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo;
#if UNITY_EDITOR
config.projectId = "37";
//config.simulationId = "15";
config.logicId = "42";
WebParameters.config = config;
onParameterRecived?.Invoke();
#else
Application.ExternalCall("loadingComplete");
#endif
}
public void ReceiveWebParameterJson(string json)
{
config = JsonConvert.DeserializeObject<SimulatorConfig>(json);
WebParameters.config = config;
onParameterRecived?.Invoke();
Debug.Log($"webparam:{json}");
}
public void ReceiveMQTTConfigJson(string json)
{
onMqttConfigReceived?.Invoke(json);
Debug.Log($"mqttconfig:{json}");
}
public void ReceiveWebConfigJson(string json)
{
onWebConfigReceived?.Invoke(json);
Debug.Log($"webconfig:{json}");
}
}
}