86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.EventSystems;
|
|||
|
|
using UnityEngine.Serialization;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
namespace LRC
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ч<EFBFBD><D0A7>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֵ<CEAA><D6B5>
|
|||
|
|
/// </summary>
|
|||
|
|
public class ConfigToggleGroup : ConfigSelectableItem
|
|||
|
|
{
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
|||
|
|
|
|||
|
|
public ToggleGroup targetToggle;
|
|||
|
|
|
|||
|
|
public List<Toggle> toggles;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
protected override void Awake()
|
|||
|
|
{
|
|||
|
|
base.Awake();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < toggles.Count; i++)
|
|||
|
|
{
|
|||
|
|
void BuildInGroupInit()
|
|||
|
|
{
|
|||
|
|
var index = i;
|
|||
|
|
var toggle = toggles[i];
|
|||
|
|
toggle.onValueChanged.AddListener(a =>
|
|||
|
|
{
|
|||
|
|
if (a)
|
|||
|
|
SetValue(index);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
BuildInGroupInit();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ʵ<EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
protected override void SetValue(object newValue)
|
|||
|
|
{
|
|||
|
|
base.SetValue(CastIntNumber(newValue));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void RefreshValueWithoutEvent(object newValue, bool forceSet = false)
|
|||
|
|
{
|
|||
|
|
base.RefreshValueWithoutEvent(CastIntNumber(newValue), forceSet);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void Initialization_ChildConstruction(UIBehaviour component)
|
|||
|
|
{
|
|||
|
|
base.Initialization_ChildConstruction(component);
|
|||
|
|
|
|||
|
|
if (component is Toggle toggle &&
|
|||
|
|
!toggles.Contains(toggle))
|
|||
|
|
toggles.Add(toggle);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void RefreshFormatValue(object newValue)
|
|||
|
|
{
|
|||
|
|
base.RefreshFormatValue(newValue);
|
|||
|
|
var newIndex = CastIntNumber(newValue);
|
|||
|
|
// var index = 0;
|
|||
|
|
// foreach (var toggle in targetToggle.ActiveToggles())
|
|||
|
|
// {
|
|||
|
|
// if (newIndex != index++)
|
|||
|
|
// continue;
|
|||
|
|
// toggle.isOn = true;
|
|||
|
|
// Debug.Log(TitleName +":<3A><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>Ŀ");
|
|||
|
|
// }
|
|||
|
|
toggles[newIndex].SetIsOnWithoutNotify(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|