add project files
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace OHM.UnityToolkit
|
||||
{
|
||||
[RequireComponent(typeof(Toggle))]
|
||||
public class UIToggleOffGraphic : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("offGraphic")]
|
||||
private Graphic _offGraphic;
|
||||
|
||||
[SerializeField]
|
||||
private Toggle toggle;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
ComponentsUtils.GetRequiredComponent(base.transform, ref toggle);
|
||||
toggle.onValueChanged.AddListener(OnToggleChanged);
|
||||
}
|
||||
|
||||
private void OnToggleChanged(bool value)
|
||||
{
|
||||
if (_offGraphic != null)
|
||||
{
|
||||
_offGraphic.gameObject.SetActive(!toggle.isOn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user