Files
Simulation/Assets/WorkSpace/LH/WebReceiver.cs
2025-05-28 20:15:13 +09:00

51 lines
1.4 KiB
C#

using Newtonsoft.Json;
using UnityEngine;
using System;
using TMPro;
using Octopus.Simulator.Networks;
using Octopus.Simulator;
using System.Runtime.InteropServices;
public class WebReceiver : MonoBehaviour
{
public SimulatorConfig config;
public event Action onParameterRecived;
public event Action<string> onMqttConfigReceived;
public event Action<string> onWebConfigReceived;
public void Start()
{
/*
Application.ExternalCall("loadingComplete");
*/
config.projectId = "17";
//config.simulationId = "15";
config.logicId = "71";
WebParameters.config = config;
onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo;
onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo;
onParameterRecived?.Invoke();
}
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}");
}
}