备份CatanBuilding瘦身独立工程
This commit is contained in:
35
Assets/Scripts/UI/Setting/ToggleWithNum.cs
Normal file
35
Assets/Scripts/UI/Setting/ToggleWithNum.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ToggleWithNum : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private int offset = 1;
|
||||
|
||||
public int num;
|
||||
public bool InvokeWhenClose=false;
|
||||
|
||||
public Toggle Toggle;
|
||||
|
||||
public UnityAction<bool, int> ChannalToggleChange;
|
||||
void Awake()
|
||||
{
|
||||
num = transform.GetSiblingIndex()-1;
|
||||
Toggle = GetComponent<Toggle>();
|
||||
Toggle. onValueChanged.AddListener(OnToggleChange);
|
||||
}
|
||||
|
||||
public void OnToggleChange(bool isOn)
|
||||
{
|
||||
if(!InvokeWhenClose&&!isOn)
|
||||
return;
|
||||
|
||||
ChannalToggleChange?.Invoke(isOn,num);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user