59 lines
1.7 KiB
C#
59 lines
1.7 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 event Action<string> onCameraReceived;
|
|
|
|
|
|
public void Start()
|
|
{
|
|
WebParameters.code = "";
|
|
onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo;
|
|
onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo;
|
|
#if UNITY_EDITOR
|
|
config.projectId = "53";
|
|
//config.simulationId = "15";
|
|
config.logicId = "58";
|
|
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}");
|
|
}
|
|
|
|
public void camAngle(string json)
|
|
{
|
|
onCameraReceived?.Invoke(json);
|
|
Debug.Log($"webCam:{json}");
|
|
}
|
|
}
|
|
} |