Files
Darklings-FightingGame/Assets/_Project/Scripts/UIScripts/TrainingSubOption.cs
kidagine 154da9bb63 update
2022-04-05 16:08:11 +02:00

30 lines
642 B
C#

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class TrainingSubOption : MonoBehaviour
{
[SerializeField] private Selectable _initialSelectable = default;
private Selectable _currentInitialSelectable;
public void Activate()
{
gameObject.SetActive(true);
if (_currentInitialSelectable == null)
{
_currentInitialSelectable = _initialSelectable;
}
_currentInitialSelectable.Select();
}
public void Disable()
{
if (gameObject.activeSelf)
{
_currentInitialSelectable = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>();
}
gameObject.SetActive(false);
}
}