91 lines
2.5 KiB
C#
91 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_FaultSituationL2Btn : MonoBehaviour
|
|
{
|
|
[HideInInspector]
|
|
public List<string> limitedFaults;
|
|
public UI_FaultSelectionRegistrationPanel mainPanel;
|
|
|
|
/// <summary>
|
|
/// 加载选中的故障
|
|
/// </summary>
|
|
/// <param name="listFromOption"></param>
|
|
public void loadLimitedFaults(List<string> listFromOption)
|
|
{
|
|
limitedFaults = new List<string>(listFromOption);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当选中时,检查故障互斥
|
|
/// </summary>
|
|
/// <param name="b"></param>
|
|
public void CheckLimtWhenSelected(bool b)
|
|
{
|
|
if (limitedFaults == null) return;
|
|
UI_FaultSituationL2Btn[] faultTogs = GameObject.FindObjectsOfType<UI_FaultSituationL2Btn>();
|
|
if (b)
|
|
{
|
|
//CheckLimtByName(this.name);
|
|
foreach (var item in faultTogs)
|
|
{
|
|
if (limitedFaults.Contains(item.gameObject.name))
|
|
{
|
|
Toggle tog = item.GetComponent<Toggle>();
|
|
tog.isOn = false;
|
|
tog.interactable = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
foreach (var item in faultTogs)
|
|
{
|
|
if (limitedFaults.Contains(item.gameObject.name))
|
|
{
|
|
Toggle tog = item.GetComponent<Toggle>();
|
|
tog.interactable = true;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < mainPanel.rightFaultGroup.transform.childCount; i++)
|
|
if (mainPanel.rightFaultGroup.transform.GetChild(i).gameObject.name.Equals(this.name))
|
|
{
|
|
DestroyImmediate(mainPanel.rightFaultGroup.transform.GetChild(i).gameObject);
|
|
break;
|
|
}
|
|
|
|
mainPanel.ResetL2FaultLimitationBySelected();
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 目前只负责关闭,不负责打开
|
|
/// </summary>
|
|
/// <param name="faultName"></param>
|
|
/*public void CheckLimtByName(string faultName)
|
|
{
|
|
UI_FaultSituationL2Btn[] faultTogs = GameObject.FindObjectsOfType<UI_FaultSituationL2Btn>();
|
|
foreach (var item in faultTogs)
|
|
{
|
|
if (limitedFaults.Contains(faultName))
|
|
{
|
|
Toggle tog = item.GetComponent<Toggle>();
|
|
tog.isOn = false;
|
|
tog.interactable = false;
|
|
}
|
|
}
|
|
}*/
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
}
|