Files
Simulation/Assets/WorkSpace/LH/ProjectDataManager.cs
2025-07-07 09:57:13 +09:00

55 lines
1.5 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;
[SerializeField]
Button projectSaveButton;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
projectMenuButton.onClick.AddListener(SetActive);
FindAnyObjectByType<Panel_SimulationUI>().onPlaying+=onPlay;
}
public void RequestInfo()
{
var reqeustURL = $"{WebManager.Instance.apiConfig.project}/{WebParameters.config.projectId}";
WebManager.Instance.Reqeust<ProjectInfoData>(reqeustURL, RequestType.GET, ProjectInfoCallback);
}
public void ProjectInfoCallback(ProjectInfoData response)
{
SetText(response.name);
WebManager.Instance.ProjectTitle = response.name;
}
void SetText(string data)
{
text.text = data;
}
void SetActive()
{
menuPanel.gameObject.SetActive(!menuPanel.gameObject.activeSelf);
}
void onPlay(bool flag)
{
projectSaveButton.interactable = !flag;
}
}
}