Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.DrawTexture 绘制纹理
# [GUI](GUI.html).DrawTexture 绘制纹理 static function *DrawTexture* (*position* : [Rect](../Rect/Rect.html), *image* : [Texture](../Texture/Texture.html), *scaleMode* : [ScaleMode](../Enumerations/ScaleMode/ScaleMode.html) = [ScaleMode.StretchToFill](../Enumerations/ScaleMode/ScaleMode.StretchToFill.html), *alphaBlend* : bool = true, *imageAspect* : float = 0) : void ### Parameters**参数** * *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 alpha blend the image on to the display (the default). If false, the picture is drawn on to the display. 图片的混合模式,是否通道混合图片显示,默认为混合通道,如果不,图片直接被绘制显示。 * *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 without changing the pixel width and height. 源图片的长宽比,如果为 0,则使用图像的长宽比。通过"宽/高"获得所需的长宽比,这允许源图像的宽高比被调整而不影响像素宽度和高度。 *Description* 描述 Draw a texture within a rectangle. 在矩形内绘制一个纹理 另见: [GUI.color](GUI.color.html), [GUI.contentColor](GUI.contentColor.html) * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Texture aTexture; void OnGUI() { if (!typeof(aTexture)) { Debug.LogError("Assign a Texture in the inspector."); return; } GUI.DrawTexture(new Rect(10, 10, 60, 60), aTexture, ScaleMode.ScaleToFit, true, 10.0F); } } ``` ``` var aTexture : Texture; function OnGUI() { if(!aTexture){ //如果不指定图片会输出这条消息 Debug.LogError("请指定一个纹理图片"); return; } //绘制一个60x60像素大小的矩形,添加一个图片将被拉伸匹配这个矩形,并且进行通道混合,图片缩放比例为10:1 GUI.DrawTexture(Rect(10,10,60,60), aTexture, ScaleMode.ScaleToFit, true, 10.0f); } ```
da
2022年5月23日 13:44
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码