using System;
using System.Collections.Generic;
using Spine.Unity;
using UnityEngine;
using UnityEngine.UI;
///
/// 特效穿透阻挡器
/// 将此脚本挂在特效游戏对象上,可以防止特效穿透UI界面
///
public class EffectPenetrationBlocker : MonoBehaviour
{
[Tooltip("是否在UI层级下自动调整排序顺序")]
public bool autoAdjustSorting = true;
[Tooltip("特效渲染器,如果为空则自动获取")]
public List effectRenderers = new List();
[Tooltip("自定义排序顺序,仅在不自动调整时有效")]
public int customSortingOrder = 0;
[Tooltip("自定义排序层,为空则使用默认UI层")]
public string customSortingLayer = "UI";
[Tooltip("特效所属的Canvas,如果为空则查找父级Canvas")]
public Canvas parentCanvas;
[Tooltip("特效在Canvas中的排序偏移量")]
public int sortingOrderOffset = 1;
public int canvasSortingOrder = 0;
public int renderQueue = 3000;//默认值
public Action onSortingChanged;
private void Awake()
{
transform.GetComponentsInChildren(true, effectRenderers);
// 如果没有指定渲染器,则自动获取
if (effectRenderers == null || effectRenderers.Count == 0)
{
transform.GetComponentsInChildren(true, effectRenderers);
}
// 查找父级Canvas
if (parentCanvas == null)
{
parentCanvas = GetComponentInParent