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 onMqttConfigReceived; public event Action onWebConfigReceived; public void Start() { onParameterRecived += FindAnyObjectByType().RequestInfo; onParameterRecived += FindAnyObjectByType().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(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}"); } } }