Files
Simulation/Assets/WorkSpace/LH/ProjectDataManager.cs
2025-06-04 18:30:27 +09:00

46 lines
1.3 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()
{
WebManager.Instance.Request_Get($"{WebManager.Instance.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);
}
}
}