This commit is contained in:
2025-09-18 17:37:43 +08:00
parent 858387bc2e
commit afc8137496
7 changed files with 211 additions and 62 deletions
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9d9bb294fcaf499299a69cdd86a8163b
timeCreated: 1758179759
+28
View File
@@ -0,0 +1,28 @@
namespace Deconstruction.UI.Interface
{
/// <summary>
/// 层级控制
/// </summary>
public interface IHierarchyControl
{
/// <summary>
/// 设置可见性
/// </summary>
public bool GetActive();
/// <summary>
/// 设置可见性
/// </summary>
public bool GetActiveInHierarchy();
/// <summary>
/// 设置可见性
/// </summary>
public void SetActive(bool active);
/// <summary>
/// 设置可见性
/// </summary>
public void SetActiveInHierarchy(bool active);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 487067e5309b46ad8b1312356751f795
timeCreated: 1758179860
+23 -2
View File
@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Deconstruction.UI.Interface;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
@@ -121,7 +122,7 @@ namespace XericLibrary.Runtime.MacroLibrary
/// </code>
/// </summary>
[Serializable]
public class ToggleMapping : IEnumerable<Toggle>
public class ToggleMapping : IEnumerable<Toggle>, IHierarchyControl
{
#region 事件委托
@@ -150,7 +151,6 @@ namespace XericLibrary.Runtime.MacroLibrary
// 当前选中的项目
private int _nowSelectToggleIndex = -1;
public Transform TogglesContext => ToggleGroup.transform;
/// <summary>
@@ -479,6 +479,27 @@ namespace XericLibrary.Runtime.MacroLibrary
=> DestroyAllToggle();
#endregion
#region 额外方法
public bool GetActive() => toggleList.Any(a => a.gameObject.activeSelf);
public bool GetActiveInHierarchy() => toggleList.Any(a => a.gameObject.activeInHierarchy);
public void SetActive(bool active)
{
ToggleGroup.gameObject.SetActivity(active);
toggleList.ForEachDo(a => a.gameObject.SetActive(active));
}
public void SetActiveInHierarchy(bool active)
{
ToggleGroup.gameObject.SetActivity(active);
toggleList.ForEachDo(a => a.gameObject.SetActivityInHierarchy(active));
}
#endregion
}
#endregion