35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using Newtonsoft.Json;
|
|
using UnityEngine;
|
|
using System;
|
|
using Simulator.Data;
|
|
using Simulator.Config;
|
|
|
|
namespace Simulator
|
|
{
|
|
public class WebReceiver : MonoBehaviour
|
|
{
|
|
public event Action onParameterRecived;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
onParameterRecived += ComponentsManager.Instance.testRequest;
|
|
#if UNITY_EDITOR
|
|
SimulationConfig.projectId = 347;
|
|
SimulationConfig.logicId = 358;
|
|
onParameterRecived?.Invoke();
|
|
#else
|
|
Application.ExternalCall("loadingComplete");
|
|
Debug.Log("call");
|
|
#endif
|
|
}
|
|
|
|
public void ReceiveWebParameterJson(string json)
|
|
{
|
|
var config = JsonConvert.DeserializeObject<SimulatorConfig>(json);
|
|
SimulationConfig.logicId = int.Parse(config.logicId);
|
|
SimulationConfig.projectId = int.Parse(config.projectId);
|
|
onParameterRecived?.Invoke();
|
|
Debug.Log($"webparam:{json}");
|
|
}
|
|
}
|
|
} |