绘制贴图
在C#编写的脚本中,在屏幕中绘制一张静态贴图,需要使用GUI.DrawTexture()方法,重载方法很多,输入参数可以在写代码时候多看下定义;参数最全的方法的原型为:
public static void DrawTexture(Rect position, Texture image, ScaleMode
scaleMode, bool alphaBlend);
//
// 摘要:
// Draw a texture within a rectangle.
//
// 参数:
// position:
// Rectangle on the screen to draw the texture within.
//
// image:
// Texture to display.
//
// scaleMode:
// How to scale the image when the aspect ratio of it doesn't fit the aspect
// ratio to be drawn within.
//
// alphaBlend:
// Whether to apply alpha blending when drawing the image (enabled by default).
//
// imageAspect:
// Aspect ratio to use for the source image. If 0 (the default), the aspect
// ratio from the image is used. Pass in w/h for the desired aspect ratio. This
// allows the aspect ratio of the source image to be adjusted w

本文介绍了如何在C#脚本中利用GUI.DrawTexture()方法进行2D贴图的绘制,详细讲解了方法的重载形式,并强调了C#与JavaScript中Rect对象的不同创建方式。同时,文章提到了资源的加载要求,资源需放在特定文件夹,并提供了加载单个资源和资源数组的方法。
最低0.47元/天 解锁文章
3129

被折叠的 条评论
为什么被折叠?



