36 lines
704 B
C#
36 lines
704 B
C#
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);
|
|
}
|
|
|
|
|
|
|
|
}
|