Files
Simulation/Assets/Scripts/ProjectDataManager.cs

55 lines
1.5 KiB
C#
Raw Normal View History

2025-06-04 18:30:27 +09:00
using UVC.Networks;
2025-05-27 19:07:12 +09:00
using UnityEngine;
using Newtonsoft.Json;
using UnityEngine.UI;
using TMPro;
2025-06-04 18:30:27 +09:00
using Octopus.Simulator.Networks;
2025-05-27 19:07:12 +09:00
2025-06-04 18:30:27 +09:00
namespace Octopus.Simulator
2025-05-27 19:07:12 +09:00
{
2025-06-04 18:30:27 +09:00
public class ProjectDataManager : MonoBehaviour
2025-05-27 19:07:12 +09:00
{
2025-06-04 18:30:27 +09:00
[SerializeField]
TMP_Text text;
[SerializeField]
Button projectMenuButton;
[SerializeField]
RectTransform menuPanel;
2025-07-07 09:57:13 +09:00
[SerializeField]
Button projectSaveButton;
2025-06-04 18:30:27 +09:00
// Start is called once before the first execution of Update after the MonoBehaviour is created
2025-07-07 09:57:13 +09:00
void Awake()
2025-06-04 18:30:27 +09:00
{
projectMenuButton.onClick.AddListener(SetActive);
2025-07-07 09:57:13 +09:00
FindAnyObjectByType<Panel_SimulationUI>().onPlaying+=onPlay;
2025-06-04 18:30:27 +09:00
}
public void RequestInfo()
2025-05-27 19:07:12 +09:00
{
2025-06-24 17:02:33 +09:00
var reqeustURL = $"{WebManager.Instance.apiConfig.project}/{WebParameters.config.projectId}";
2025-07-07 09:57:13 +09:00
2025-06-24 17:02:33 +09:00
WebManager.Instance.Reqeust<ProjectInfoData>(reqeustURL, RequestType.GET, ProjectInfoCallback);
}
public void ProjectInfoCallback(ProjectInfoData response)
{
SetText(response.name);
2025-07-07 09:57:13 +09:00
WebManager.Instance.ProjectTitle = response.name;
2025-06-04 18:30:27 +09:00
}
2025-05-27 19:07:12 +09:00
2025-06-04 18:30:27 +09:00
void SetText(string data)
{
text.text = data;
}
void SetActive()
{
menuPanel.gameObject.SetActive(!menuPanel.gameObject.activeSelf);
}
2025-07-07 09:57:13 +09:00
void onPlay(bool flag)
{
2025-07-08 13:42:26 +09:00
projectSaveButton.interactable = false;
2025-07-07 09:57:13 +09:00
}
2025-05-27 19:07:12 +09:00
}
2025-06-04 18:30:27 +09:00
}