Drawing.FillRect C# (CSharp) Метод

FillRect() публичный статический Метод

矩形塗りつぶし
public static FillRect ( Rect rect, Color color ) : void
rect Rect
color Color
Результат void
    public static void FillRect(Rect rect, Color color)
    {
        if (rect.xMax == 0 || rect.yMax == 0) { return; }

        #if UNITY_EDITOR
        if (!lineTex)
        {
            Initialize();
        }
        #endif

        // We shouldn't draw until we are told to do so.
        //if (Event.current.type != EventType.Repaint)
        //	return;

        // Please assign a material that is using position and color.
        //if (material == null)
        //{
        //	Debug.LogError("You have forgot to set a material.");
        //	return;
        //}

        Texture2D tex = lineTex;
        Material mat = blitMaterial;
        Graphics.DrawTexture(rect, tex, rect, 0, 0, 0, 0, color, mat);
    }

Usage Example

Пример #1
0
        /// <summary>
        /// 矩形塗りつぶし
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="color"></param>
        static public void Fill(Rect rect, Color color)
        {
            if (rect.xMax == 0 || rect.yMax == 0)
            {
                return;
            }

            Color tmp = GUI.color;

#if true
            Drawing.FillRect(rect, color);
#else
            // GUIを使ってるのでOnDrawGUIで描画しないと他のボタンとかが反応しなくなることが...何それ。
            //Texture2D tex = GUI.skin.box.normal.background;

            GUI.color = color;
            //GUI.Box(rect, "");

            //Texture2D texture = new Texture2D(1, 1);
            //texture.SetPixel(0, 0, color);
            //texture.Apply();
            //GUI.skin.box.normal.background = texture;
            GUI.Box(rect, GUIContent.none);

            //GUI.skin.box.normal.background = tex;
#endif
            GUI.color = tmp;
        }