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

50 lines
1.5 KiB
C#
Raw Normal View History

2025-05-08 10:18:15 +09:00
using System.Collections.Generic;
2025-05-02 17:51:34 +09:00
using UnityEngine;
using UnityEngine.UI;
using Octopus.Simulator;
using Octopus.Simulator.Networks;
2025-05-08 10:18:15 +09:00
using TMPro;
2025-05-02 17:51:34 +09:00
public class Panel_SimulationUI : MonoBehaviour
{
WebManager webmanager;
2025-05-08 10:18:15 +09:00
Button Button_Play;
Button Button_FastForward;
TMP_Text text_FastForward;
List<int> fastParam = new List<int> { 1, 2, 3, 5, 10 };
int currentFastIndex = 0;
private void Awake()
{
Button_Play = transform.Find(nameof(Button_Play)).GetComponent<Button>();
Button_FastForward = transform.Find(nameof(Button_FastForward)).GetComponent<Button>();
text_FastForward = Button_FastForward.GetComponentInChildren<TMP_Text>();
}
2025-05-02 17:51:34 +09:00
private void Start()
{
webmanager = WebManager.webManager;
2025-05-08 10:18:15 +09:00
Button_Play.onClick.AddListener(OnClickPlayBTN);
Button_FastForward.onClick.AddListener(OnclickFastForwardBTN);
2025-05-02 17:51:34 +09:00
}
void OnClickPlayBTN()
{
SimulationParameters param = new SimulationParameters();
param.realtime = true;
param.speed = WebParameters.speed;
string requestAPI = $"{webmanager.apiConfig.history}/{WebParameters.id}/start";
webmanager.Request_Post(param, requestAPI, (flag, value) => { if (flag) { Debug.Log(value); } });
}
2025-05-08 10:18:15 +09:00
void OnclickFastForwardBTN()
{
if (currentFastIndex++ >= fastParam.Count-1)
{
currentFastIndex = 0;
}
WebParameters.speed = fastParam[currentFastIndex];
text_FastForward.text = $"x{fastParam[currentFastIndex]}";
}
2025-05-02 17:51:34 +09:00
}