Example #1
0
        public static LTRect element(LTRect rect, int depth)
        {
            isGUIEnabled = true;
            init();
            int num  = depth * RECTS_PER_LEVEL + RECTS_PER_LEVEL;
            int num2 = 0;

            if (rect != null)
            {
                destroy(rect.id);
            }
            if (rect.type == Element_Type.Label && rect.style != null)
            {
                Color textColor = rect.style.normal.textColor;
                if (textColor.a <= 0f)
                {
                    Debug.LogWarning("Your GUI normal color has an alpha of zero, and will not be rendered.");
                }
            }
            if (rect.relativeRect.width == float.PositiveInfinity)
            {
                rect.relativeRect = new Rect(0f, 0f, Screen.width, Screen.height);
            }
            for (int i = depth * RECTS_PER_LEVEL; i < num; i++)
            {
                r = levels[i];
                if (r == null)
                {
                    r = rect;
                    r.rotateEnabled = true;
                    r.alphaEnabled  = true;
                    r.setId(i, global_counter);
                    levels[i] = r;
                    if (num2 >= levelDepths[depth])
                    {
                        levelDepths[depth] = num2 + 1;
                    }
                    global_counter++;
                    return(r);
                }
                num2++;
            }
            Debug.LogError("You ran out of GUI Element spaces");
            return(null);
        }