using System.Collections.Generic;
using UnityEngine.Pool;
namespace UnityEngine.UI
{
///
/// Mask related utility class. This class provides masking-specific utility functions.
///
public class MaskUtilities
{
///
/// Notify all IClippables under the given component that they need to recalculate clipping.
///
/// The object thats changed for whose children should be notified.
public static void Notify2DMaskStateChanged(Component mask)
{
var components = ListPool.Get();
mask.GetComponentsInChildren(components);
for (var i = 0; i < components.Count; i++)
{
if (components[i] == null || components[i].gameObject == mask.gameObject)
continue;
var toNotify = components[i] as IClippable;
if (toNotify != null)
toNotify.RecalculateClipping();
}
ListPool.Release(components);
}
///
/// Notify all IMaskable under the given component that they need to recalculate masking.
///
/// The object thats changed for whose children should be notified.
public static void NotifyStencilStateChanged(Component mask)
{
var components = ListPool.Get();
mask.GetComponentsInChildren(components);
for (var i = 0; i < components.Count; i++)
{
if (components[i] == null || components[i].gameObject == mask.gameObject)
continue;
var toNotify = components[i] as IMaskable;
if (toNotify != null)
toNotify.RecalculateMasking();
}
ListPool.Release(components);
}
///
/// Find a root Canvas.
///
/// Transform to start the search at going up the hierarchy.
/// Finds either the most root canvas, or the first canvas that overrides sorting.
public static Transform FindRootSortOverrideCanvas(Transform start)
{
var canvasList = ListPool