예제 #1
0
 public override void Draw(
     float offsetX,
     float offsetY,
     Renderer2D renderer)
 {
     renderer.Color = new Color32(255, 255, 255, 255);
     if (sprite != null)
     {
         renderer.AddSprite(
             offsetX + LocalLeftX,
             offsetY + LocalTopY,
             Width,
             Height,
             sprite);
     }
     else if (texture != null)
     {
         renderer.AddTexturedRectangle(
             offsetX + LocalLeftX,
             offsetY + LocalTopY,
             Width,
             Height,
             texture);
     }
     else
     {
         renderer.AddRectangle(
             offsetX + LocalLeftX,
             offsetY + LocalTopY,
             Width,
             Height);
     }
 }
예제 #2
0
        public override void Draw(
            float offsetX,
            float offsetY,
            Renderer2D renderer)
        {
            // 棒を描画
            float ratio;

            if (mode == Mode.Log10)
            {
                float logMin = Mathf.Log10(min);
                float logMax = Mathf.Log10(max);
                ratio = (Mathf.Log10(Value) - logMin) / (logMax - logMin);
            }
            else
            {
                ratio = (Value - min) / (max - min);
            }
            ratio = (ratio < 0f) ? 0f : ((ratio > 1f) ? 1f : ratio);
            float barWidth = (Width - (2f * BorderWidth)) * ratio;

            renderer.Color = GaugeColor;
            renderer.AddRectangle(
                offsetX + LocalLeftX + BorderWidth,
                offsetY + LocalTopY + BorderWidth,
                barWidth,
                Height - (2f * BorderWidth));

            // 題名
            renderer.Color = TextColor;
            if (text.Length > 0)
            {
                renderer.AddText(
                    text,
                    offsetX + LocalLeftX + (BorderWidth * 2f),
                    offsetY + LocalTopY + (BorderWidth * 2f),
                    Width - (BorderWidth * 2f),
                    Height - (BorderWidth * 2f));
            }

            string formatString = (mode == Mode.Integer) ? "F0" : "F2";

            // 数字は右寄せ
            renderer.AddText(
                Value.ToString(formatString),
                offsetX + LocalLeftX + Width - (BorderWidth * 2f),
                offsetY + LocalTopY + (BorderWidth * 2f),
                Width - (BorderWidth * 2f),
                Height - (BorderWidth * 2f),
                AlignX.Right);
        }
예제 #3
0
        public override void Draw(
            float offsetX,
            float offsetY,
            Renderer2D renderer)
        {
            Color32 tmpColor = (On) ? OnColor : OffColor;

            renderer.Color = tmpColor;
            if (sprite != null)
            {
                renderer.AddSprite(
                    offsetX + LocalLeftX + BorderWidth,
                    offsetY + LocalTopY + BorderWidth,
                    Width - (BorderWidth * 2f),
                    Height - (BorderWidth * 2f),
                    sprite);
            }
            else if (texture != null)
            {
                renderer.AddTexturedRectangle(
                    offsetX + LocalLeftX + BorderWidth,
                    offsetY + LocalTopY + BorderWidth,
                    Width - (BorderWidth * 2f),
                    Height - (BorderWidth * 2f),
                    texture);
            }
            else
            {
                renderer.AddRectangle(
                    offsetX + LocalLeftX + BorderWidth,
                    offsetY + LocalTopY + BorderWidth,
                    Width - (BorderWidth * 2f),
                    Height - (BorderWidth * 2f));
            }

            Color32 tmpTextColor = (On) ? OnTextColor : OffTextColor;

            renderer.Color = tmpTextColor;
            renderer.AddText(
                Text,
                offsetX + LocalLeftX + (Width * 0.5f),
                offsetY + LocalTopY + (Height * 0.5f),
                Width - (BorderWidth * 4f),
                Height - (BorderWidth * 4f),
                AlignX.Center,
                AlignY.Center);
        }
예제 #4
0
        void DrawGauge(
            float offsetX,
            float offsetY,
            Renderer2D renderer,
            float value,
            Color32 color)
        {
            // seconadary
            float ratio = (value - min) / (max - min);

            ratio = (ratio < 0f) ? 0f : ((ratio > 1f) ? 1f : ratio);
            float length = ratio * (Width - (2f * BorderWidth));

            renderer.Color = color;
            renderer.AddRectangle(
                offsetX + LocalLeftX + BorderWidth,
                offsetY + LocalTopY + BorderWidth,
                length,
                Height - (2f * BorderWidth));
        }
예제 #5
0
        public void DrawRecursive(
            float offsetX,
            float offsetY,
            Renderer2D renderer)
        {
            if (!enabled)
            {
                return;
            }

            // まず自分描画
            if (BackgroundEnabled)
            {
                renderer.Color = BackgroundColor;
                renderer.AddRectangle(
                    offsetX + LocalLeftX,
                    offsetY + LocalTopY,
                    Width,
                    Height);
            }
            if (BorderEnabled)
            {
                renderer.Color = BorderColor;
                renderer.AddRectangleFrame(
                    offsetX + LocalLeftX,
                    offsetY + LocalTopY,
                    Width,
                    Height,
                    BorderWidth);
            }
            Draw(offsetX, offsetY, renderer);

            // グローバル座標を計算して子を描画
            float globalLeftX = offsetX + LocalLeftX;
            float globalTopY  = offsetY + LocalTopY;

            DrawChildren(globalLeftX, globalTopY, renderer);
            DrawPostChild(offsetX, offsetY, renderer);
        }