Unity3d⼀NGUI 在面板上画图。

2025-04-27 23:18:36
推荐回答(1个)
回答1:

可以参考NGUIEditorTools.cs里的这个方法自己实现
///


/// Draws the tiled texture. Like GUI.DrawTexture() but tiled instead of stretched.
///


static public void DrawTiledTexture (Rect rect, Texture tex)
{
GUI.BeginGroup(rect);
{
int width = Mathf.RoundToInt(rect.width);
int height = Mathf.RoundToInt(rect.height);

for (int y = 0; y < height; y += tex.height)
{
for (int x = 0; x < width; x += tex.width)
{
GUI.DrawTexture(new Rect(x, y, tex.width, tex.height), tex);
}
}
}
GUI.EndGroup();
}

我的博客中有讲解 http://www.blog1314.com/article/21.html