104 lines
2.7 KiB
C#
104 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 任务分解项,用于在执行模拟界面中展示单个任务的分解详情。
|
|
/// </summary>
|
|
public class BreakdownTaskItem : MonoBehaviour
|
|
{
|
|
public Text currentIndexText;
|
|
public Transform parentTrans;
|
|
public Button upBtn;
|
|
public Button downBtn;
|
|
public InputField nameInput;
|
|
public InputField timeInput;
|
|
|
|
public ExecuteSimulationView executeSimulation;
|
|
|
|
public int index = 0;
|
|
|
|
public int SetCurrentIndex
|
|
{
|
|
set
|
|
{
|
|
currentIndexText.text = value.ToString();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新界面元素,主要是更新索引和按钮交互状态
|
|
/// </summary>
|
|
public void Start()
|
|
{
|
|
index = transform.GetSiblingIndex();
|
|
currentIndexText.text = (index + 1).ToString();
|
|
|
|
if (index == parentTrans.childCount - 1)
|
|
downBtn.interactable = false;
|
|
if (index == 0)
|
|
upBtn.interactable = false;
|
|
|
|
upBtn.onClick.AddListener(() =>
|
|
{
|
|
transform.SetSiblingIndex(index - 1);
|
|
executeSimulation.Refresh();
|
|
});
|
|
downBtn.onClick.AddListener(() =>
|
|
{
|
|
transform.SetSiblingIndex(index - -1);
|
|
|
|
executeSimulation.Refresh();
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 刷新界面元素
|
|
/// </summary>
|
|
public void Refresh()
|
|
{
|
|
index = transform.GetSiblingIndex();
|
|
currentIndexText.text = (index + 1).ToString();
|
|
|
|
if (index == parentTrans.childCount - 1)
|
|
downBtn.interactable = false;
|
|
else
|
|
downBtn.interactable = true;
|
|
|
|
if (index == 0)
|
|
upBtn.interactable = false;
|
|
else
|
|
upBtn.interactable = true;
|
|
}
|
|
public void InitData()
|
|
{
|
|
nameInput.text = string.Empty;
|
|
timeInput.text = string.Empty;
|
|
}
|
|
|
|
public void DisabledAll()
|
|
{
|
|
nameInput.interactable =false;
|
|
timeInput.interactable =false;
|
|
downBtn.interactable =false;
|
|
upBtn.interactable =false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭编辑模式
|
|
/// </summary>
|
|
public void CloseEdit()
|
|
{
|
|
if (!UIUtils.Instance.IsInputCorrect(nameInput) || !UIUtils.Instance.IsInputCorrect(timeInput))
|
|
{
|
|
//GetVariable<ExecuteSimulationView>("my_executeSimulation").
|
|
executeSimulation.ShowWarming("任务名、时长不可为空!");
|
|
}
|
|
|
|
nameInput.interactable = false;
|
|
timeInput.interactable = false;
|
|
upBtn.interactable = false;
|
|
downBtn.interactable = false;
|
|
}
|
|
} |