using Nova;
using UnityEngine;
namespace NovaSamples.UIControls
{
///
/// An abstract base class used to share common functionality of various UI controls (e.g. Button, Toggle, Slider, Dropdown, etc.)
///
/// The type of used to represent this UI control.
[RequireComponent(typeof(ItemView))]
public abstract class UIControl : MonoBehaviour where T : ItemVisuals
{
///
/// The view holding the visuals representing this control
///
private ItemView view = null;
///
/// The view holding the visuals representing this control
///
protected ItemView View
{
get
{
if (view == null)
{
// ItemView is a required component, so it's safe to assume it's there.
view = GetComponent();
if (!(view.Visuals is T))
{
Debug.LogError($"Attached {nameof(ItemView)} expected to have a Visuals of Type {typeof(T).Name}", this);
}
}
return view;
}
}
}
}