codecamp

UGUI Image 控件

Unity 3D Image 控件除了两个公共的组件 Rect TransformCanvas Renderer 外,默认的情况下就只有一个 Image 组件,如下图所示。

其中,Source Image 是要显示的源图像,要想把一个图片赋给 Image,需要把图片转换成精灵格式,转化后的精灵图片就可拖放到 ImageSource Image 中了。

转换方法为:在 Project 视图中选中要转换的图片,然后在 Inspector 属性面板中,单击 Texture Type(纹理类型)右边的下拉列表,选中 Sprite(2D and UI)并单击下方的 Apply 按钮,就可以把图片转换成精灵格式,然后就可以拖放到 ImageSource Image 中了。

参数列表

参数 描述
Color 设置应用在图片上的颜色
Material 设置应用在图片上的材质
Image Type 设置贴图类型
UGUI Text 控件
UGUI Raw Image 控件
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }