43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Octopus.Simulator.Networks;
|
|
using UnityEngine;
|
|
using Newtonsoft.Json;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
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()
|
|
{
|
|
WebManager.webManager.Request_Get($"{WebManager.webManager.apiConfig.project}/{WebParameters.config.projectId}", (flag, value) =>
|
|
{
|
|
if (flag)
|
|
{
|
|
var info = JsonConvert.DeserializeObject<ProjectInfo>(value);
|
|
SetText(info.data.name);
|
|
}
|
|
});
|
|
}
|
|
|
|
void SetText(string data)
|
|
{
|
|
text.text = data;
|
|
}
|
|
void SetActive()
|
|
{
|
|
menuPanel.gameObject.SetActive(!menuPanel.gameObject.activeSelf);
|
|
}
|
|
}
|