using Newtonsoft.Json; using UnityEngine; using System; using System.Collections.Generic; namespace Octopus.Simulator.Networks { public class WebReceiver : MonoBehaviour { public SimulatorConfig config; public event Action onParameterRecived; public event Action onMqttConfigReceived; public event Action onWebConfigReceived; public event Action onCameraReceived; public event Action onCompleteWindowReceived; public event Action onLLMModelsReceived; public event Action onLLMModelsUpdated; public void Start() { WebParameters.code = ""; onParameterRecived += FindAnyObjectByType().RequestInfo; onParameterRecived += FindAnyObjectByType().RequestInfo; #if UNITY_EDITOR config.projectId = "78"; //config.simulationId = "15"; config.logicId = "83"; WebParameters.config = config; onParameterRecived?.Invoke(); #else Application.ExternalCall("loadingComplete"); #endif } private void Update() { if(Input.GetKeyDown(KeyCode.G)){ var text=Resources.Load("simulation_model_infos_list"); ReceiveLLMModels(text.text); } if (Input.GetKeyDown(KeyCode.F)) { var text = Resources.Load("simulation_model_infos_list_add"); ReceiveLLMUpdate(text.text); } } 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}"); } public void camAngle(string json) { onCameraReceived?.Invoke(json); Debug.Log($"webCam:{json}"); } public void ReceiveLLMModels(string json) { var data = JsonConvert.DeserializeObject(json); onLLMModelsReceived?.Invoke(data.info); } public void ReceiveLLMUpdate(string json) { var data = JsonConvert.DeserializeObject(json); onLLMModelsUpdated?.Invoke(data.info); } public void ReceiveCompleteWindow() { onCompleteWindowReceived?.Invoke(); Debug.Log("CompleteReceive"); } public void SetKeyBoardOn() { WebGLInput.captureAllKeyboardInput = true; } public void SetKeyBoardOff() { WebGLInput.captureAllKeyboardInput = false; } } public class LLMWraper { public string info; } }