Files
Simulation/Assets/WorkSpace/LH/ProjectDataManager.cs

55 lines
1.6 KiB
C#

using UVC.Networks;
using UnityEngine;
using Newtonsoft.Json;
using UnityEngine.UI;
using TMPro;
using Octopus.Simulator.Networks;
namespace Octopus.Simulator
{
public class ProjectDataManager : MonoBehaviour
{
[SerializeField]
TMP_Text text;
[SerializeField]
Button projectMenuButton;
[SerializeField]
RectTransform menuPanel;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
FindAnyObjectByType<WebReceiver>().onParameterRecived += RequestInfo;
projectMenuButton.onClick.AddListener(SetActive);
}
public void RequestInfo()
{
var reqeustURL = $"{WebManager.Instance.apiConfig.project}/{WebParameters.config.projectId}";
WebManager.Instance.Reqeust<ProjectInfoData>(reqeustURL, RequestType.GET, ProjectInfoCallback);
//WebManager.Instance.Request_Get(reqeustURL, (flag, value) =>
//{
// if (flag)
// {
// var info = JsonConvert.DeserializeObject<ProjectInfo>(value);
// SetText(info.data.name);
// }
//});
}
public void ProjectInfoCallback(ProjectInfoData response)
{
SetText(response.name);
}
void SetText(string data)
{
text.text = data;
}
void SetActive()
{
menuPanel.gameObject.SetActive(!menuPanel.gameObject.activeSelf);
}
}
}