switch set, automatize more of the content without UI change
This commit is contained in:
55
Assets/UI/ChampionBaseUI.cs
Normal file
55
Assets/UI/ChampionBaseUI.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Set.Data;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ChampionBaseUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Text _championNameText;
|
||||
|
||||
[SerializeField]
|
||||
private Toggle _championToggle;
|
||||
|
||||
private ChampionsEnum _championType;
|
||||
private bool _defaultSelected = false;
|
||||
|
||||
public ChampionsEnum ChampionType => _championType;
|
||||
public bool IsSelected => _championToggle != null ? _championToggle.isOn : false;
|
||||
|
||||
public void Initialize(
|
||||
ChampionsEnum championType,
|
||||
string championDisplayName,
|
||||
bool defaultSelected = false
|
||||
)
|
||||
{
|
||||
_championType = championType;
|
||||
_championNameText.text = championDisplayName;
|
||||
_defaultSelected = defaultSelected;
|
||||
|
||||
// Set default selection state
|
||||
if (_championToggle != null)
|
||||
_championToggle.isOn = defaultSelected;
|
||||
}
|
||||
|
||||
public void SetSelected(bool selected)
|
||||
{
|
||||
if (_championToggle != null)
|
||||
_championToggle.isOn = selected;
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
if (_championToggle != null)
|
||||
_championToggle.isOn = _defaultSelected;
|
||||
}
|
||||
|
||||
public void SetInteractable(bool interactable)
|
||||
{
|
||||
if (_championToggle != null)
|
||||
_championToggle.interactable = interactable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user