namespace UIWidgets
{
using System;
using System.Collections.Generic;
using UIWidgets.Attributes;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
using UnityEngine.UI;
///
/// Base class for TracksView.
///
/// Data type.
/// Point type.
public abstract class TracksViewBase : UIBehaviourConditional, IUpdatable
where TData : class, ITrackData
where TPoint : IComparable
{
#region Interactable
///
/// The CanvasGroup cache.
///
protected readonly List CanvasGroupCache = new List();
[SerializeField]
bool interactable = true;
///
/// Is widget interactable.
///
/// true if interactable; otherwise, false.
public bool Interactable
{
get
{
return interactable;
}
set
{
if (interactable != value)
{
interactable = value;
InteractableChanged();
}
}
}
///
/// If the canvas groups allow interaction.
///
protected bool GroupsAllowInteraction = true;
///
/// Process the CanvasGroupChanged event.
///
protected override void OnCanvasGroupChanged()
{
var groupAllowInteraction = true;
var t = transform;
while (t != null)
{
t.GetComponents(CanvasGroupCache);
var shouldBreak = false;
foreach (var canvas_group in CanvasGroupCache)
{
if (!canvas_group.interactable)
{
groupAllowInteraction = false;
shouldBreak = true;
}
shouldBreak |= canvas_group.ignoreParentGroups;
}
if (shouldBreak)
{
break;
}
t = t.parent;
}
if (groupAllowInteraction != GroupsAllowInteraction)
{
GroupsAllowInteraction = groupAllowInteraction;
InteractableChanged();
}
}
///
/// Determines whether this widget is interactable.
///
/// true if this instance is interactable; otherwise, false.
public virtual bool IsInteractable()
{
return GroupsAllowInteraction && Interactable;
}
///
/// Process interactable change.
///
protected virtual void InteractableChanged()
{
if (IsInteractable())
{
OnInteractableEnabled();
}
else
{
OnInteractableDisabled();
}
}
///
/// What to do when widget became interactable.
///
protected virtual void OnInteractableEnabled()
{
}
///
/// What to do when widget became not interactable.
///
protected virtual void OnInteractableDisabled()
{
}
#endregion
[SerializeField]
[HideInInspector]
ObservableList