From e7dfbec8e8634e767d78959941daf71a96e021cf Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Apr 2021 19:10:30 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UnityEngine.UI/UI/Core/MaskUtilities.cs | 182 --------------------- 1 file changed, 182 deletions(-) delete mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs deleted file mode 100644 index c975dc6..0000000 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System.Collections.Generic; -using UnityEngine.EventSystems; - -namespace UnityEngine.UI -{ - public class MaskUtilities - { - 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); - } - - 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); - } - - public static Transform FindRootSortOverrideCanvas(Transform start) - { - var canvasList = ListPool.Get(); - start.GetComponentsInParent(false, canvasList); - Canvas canvas = null; - - for (int i = 0; i < canvasList.Count; ++i) - { - canvas = canvasList[i]; - - // We found the canvas we want to use break - if (canvas.overrideSorting) - break; - } - ListPool.Release(canvasList); - - return canvas != null ? canvas.transform : null; - } - - public static int GetStencilDepth(Transform transform, Transform stopAfter) - { - var depth = 0; - if (transform == stopAfter) - return depth; - - var t = transform.parent; - var components = ListPool.Get(); - while (t != null) - { - t.GetComponents(components); - for (var i = 0; i < components.Count; ++i) - { - if (components[i] != null && components[i].MaskEnabled() && components[i].graphic.IsActive()) - { - ++depth; - break; - } - } - - if (t == stopAfter) - break; - - t = t.parent; - } - ListPool.Release(components); - return depth; - } - - public static bool IsDescendantOrSelf(Transform father, Transform child) - { - if (father == null || child == null) - return false; - - if (father == child) - return true; - - while (child.parent != null) - { - if (child.parent == father) - return true; - - child = child.parent; - } - - return false; - } - - public static RectMask2D GetRectMaskForClippable(IClippable clippable) - { - List rectMaskComponents = ListPool.Get(); - List canvasComponents = ListPool.Get(); - RectMask2D componentToReturn = null; - - clippable.rectTransform.GetComponentsInParent(false, rectMaskComponents); - - if (rectMaskComponents.Count > 0) - { - for (int rmi = 0; rmi < rectMaskComponents.Count; rmi++) - { - componentToReturn = rectMaskComponents[rmi]; - if (componentToReturn.gameObject == clippable.gameObject) - { - componentToReturn = null; - continue; - } - if (!componentToReturn.isActiveAndEnabled) - { - componentToReturn = null; - continue; - } - clippable.rectTransform.GetComponentsInParent(false, canvasComponents); - for (int i = canvasComponents.Count - 1; i >= 0; i--) - { - if (!IsDescendantOrSelf(canvasComponents[i].transform, componentToReturn.transform) && canvasComponents[i].overrideSorting) - { - componentToReturn = null; - break; - } - } - return componentToReturn; - } - } - - ListPool.Release(rectMaskComponents); - ListPool.Release(canvasComponents); - - return componentToReturn; - } - - public static void GetRectMasksForClip(RectMask2D clipper, List masks) - { - masks.Clear(); - - List canvasComponents = ListPool.Get(); - List rectMaskComponents = ListPool.Get(); - clipper.transform.GetComponentsInParent(false, rectMaskComponents); - - if (rectMaskComponents.Count > 0) - { - clipper.transform.GetComponentsInParent(false, canvasComponents); - for (int i = rectMaskComponents.Count - 1; i >= 0; i--) - { - if (!rectMaskComponents[i].IsActive()) - continue; - bool shouldAdd = true; - for (int j = canvasComponents.Count - 1; j >= 0; j--) - { - if (!IsDescendantOrSelf(canvasComponents[j].transform, rectMaskComponents[i].transform) && canvasComponents[j].overrideSorting) - { - shouldAdd = false; - break; - } - } - if (shouldAdd) - masks.Add(rectMaskComponents[i]); - } - } - - ListPool.Release(rectMaskComponents); - ListPool.Release(canvasComponents); - } - } -} -- cgit v1.1-26-g67d0