Ejemplo n.º 1
0
    public static void PlayUI(this ParticleLoader loader, Renderer r, int deltaRQ, Action <ParticleControl> loadCallback = null, Action <ParticleControl> endCallback = null)
    {
        if (loader == null)
        {
            return;
        }
        UIPanel p = loader.GetComponentInParent <UIPanel>();

        if (p != null)
        {
            loader.Play(particle =>
            {
                if (particle != null)
                {
                    particle.SetRqDelta(r, deltaRQ);
                }
                else
                {
                    Assert.IsNotNull(particle);
                }
                loadCallback.Call(particle);
            }, endCallback);
        }
        else
        {
            loader.Play(loadCallback, endCallback);
        }
    }
Ejemplo n.º 2
0
        public static void ToNormalColor(this UISprite s)
        {
            if (s == null || s.atlas == null)
            {
                Assert.IsTrue(false);
                return;
            }
            GrayAtlas a = grayAtlas.Get(s.atlas.name);

            if (a != null)
            {
                s.atlas = a.src;
            }
        }
Ejemplo n.º 3
0
    public static void SetLayerOver(this UIPanel over, UIPanel[] belowPanels)
    {
        UIPanel[] overPanels = over.GetComponentsInChildren <UIPanel>(true);
        Array.Sort(overPanels, (p1, p2) => p1.depth - p2.depth);

        int maxDepth = -1;

        foreach (UIPanel p in belowPanels)
        {
            maxDepth = Math.Max(maxDepth, p.depth);
        }
        int minDepth = int.MaxValue;

        foreach (UIPanel p in overPanels)
        {
            minDepth = Math.Min(minDepth, p.depth);
        }
        if (minDepth == int.MaxValue)
        {
            minDepth = 0;
        }
        int baseDepth = Math.Max(0, maxDepth - minDepth + 1);

        Assert.IsTrue(baseDepth < 20000);
        // depth must be equal or above 100
        foreach (UIPanel p in overPanels)
        {
                        #if RQ
            p.depth = Math.Max(100, p.depth + baseDepth);
                        #else
            p.depth = p.depth + baseDepth;
                        #endif
        }

        int belowMaxQ = -1;
        foreach (UIPanel p in belowPanels)
        {
            int q = p.GetMaxRenderQueue();
            if (q >= 0)
            {
                belowMaxQ = Math.Max(belowMaxQ, q);
            }
        }
        if (belowMaxQ >= 0)
        {
            int overMinQ = int.MaxValue;
            foreach (UIPanel p in overPanels)
            {
                int q = p.GetMinRenderQueue();
                if (q >= 0)
                {
                    overMinQ = Math.Min(overMinQ, q);
                }
            }
            int baseQ = belowMaxQ - overMinQ + 1;
            foreach (UIPanel p in overPanels)
            {
                if (p.gameObject.activeInHierarchy && p.renderQueue != UIPanel.RenderQueue.Explicit)
                {
                    p.renderQueue = UIPanel.RenderQueue.StartAt;
                    if (overMinQ != int.MaxValue)
                    {
                        if (baseQ > 0)
                        {
                            p.startingRenderQueue += baseQ;
                        }
                    }
                    else
                    {
                        p.startingRenderQueue = belowMaxQ + (p.depth - minDepth) * 10;                   // 10 delta per depth
                    }
                }
            }
        }

        int maxOrder = -1;
        foreach (UIPanel p in belowPanels)
        {
            maxOrder = Math.Max(maxOrder, p.sortingOrder);
        }
        // get non-NGUI renderer
        if (belowPanels.IsNotEmpty())
        {
            foreach (Renderer r in belowPanels[0].GetComponentsInChildren <Renderer>(true))
            {
                maxOrder = Math.Max(maxOrder, r.sortingOrder);
            }
        }

        SetMinSortingOrder(over, overPanels, maxOrder);

        over.Invalidate(true);
    }