yyl
6 天以前 f1e6527fd1a9281e254c000e21afb96c2da92e1c
Main/Component/UI/Common/SkeletonIllusionShadow.cs
@@ -13,37 +13,40 @@
    private readonly List<GameObject> illusionShadows = new List<GameObject>();
    private SkeletonAnimation skeletonAnimation;
    private Color color = Color.white;
    private bool createSwitch = false;
    private int curFrame = 0;
    private int frameInteral = 4;
    private int frameInteral = 6;
    public void SetSkeletonAnimation(SkeletonAnimation _skeletonAnimation)
    {
        skeletonAnimation = _skeletonAnimation;
    }
    public void Show(bool v)
    public void Show(bool v, Color _color = default)
    {
        createSwitch = v;
        curFrame = 0;
        color = _color;
        
        if (!v)
        {
            // 清理所有残影对象
            for (int i = illusionShadows.Count - 1; i >= 0; i--)
            {
                var go = illusionShadows[i];
                if (go != null)
                {
                    DOTween.Kill(go, complete: false);
                    if (Application.isPlaying)
                        Destroy(go);
                    else
                        DestroyImmediate(go);
                }
            }
            illusionShadows.Clear();
            // for (int i = illusionShadows.Count - 1; i >= 0; i--)
            // {
            //     var go = illusionShadows[i];
            //     if (go != null)
            //     {
            //         DOTween.Kill(go, complete: false);
            //         if (Application.isPlaying)
            //             Destroy(go);
            //         else
            //             DestroyImmediate(go);
            //     }
            // }
            // illusionShadows.Clear();
        }
    }
@@ -91,9 +94,12 @@
        sa.timeScale = 0;
        RendererAdjuster parent = skeletonAnimation.GetComponentInParent<RendererAdjuster>();
        objTest.AddMissingComponent<RendererAdjuster>().SetSortingOrder(parent.sortingOrder);
        objTest.AddMissingComponent<RendererAdjuster>().SetSortingOrder(parent.sortingOrder - 1);
        sa.skeleton.A = skeletonAnimation.skeleton.A;
        sa.skeleton.R = color.r;
        sa.skeleton.G = color.g;
        sa.skeleton.B = color.b;
        sa.skeleton.A = 0.5F; //skeletonAnimation.skeleton.A;
        // 使用DoTween做alpha淡出,Tween与objTest绑定,便于统一Kill
        DOTween.To(() => sa.skeleton.A, x => { sa.skeleton.A = x; sa.LateUpdate(); }, 0f, 1f)
            .SetTarget(objTest);