unity image 加载中为什么用resources.load把image加载在canvas的子

如何动态设置 Image的Sprite?【unity3d吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:76,495贴子:
如何动态设置 Image的Sprite?收藏
虽然吧里回答问题的人越来越少了,但我还是想问。怎么动态设置Image里面的Sprite。我知道Resources.Load可以。但如果把图片放到Resource目录里就无法用Sprite Packer了。求解~!如何动态更新更是个问题。网上看到雨松MOMO说把图片绑到Perfab上。难道真的只有这个解决方法?
网站建设,快速实现全网营销,费用超低
不用啊。首先你得获得动态的Sprite。比如你直接 public Sprite[]//直接资源里的图片拖进去就行public Iimg.Sprite = images[0];就这么简单啊。
Resources.Load 获得Texture,Sprite.Create(Texture2D,Rect,Vector2,float) 变换为 Sprite
还有人用UGUI嘛??自顶~!
一般的sprite,在各种Load函数里面我们一般是直接强制转换obj变为所需类型的,但是这样在sprite和某些数据类型是不行的,动态的添加sprite可以使用重载函数Sprite tempType = new Sprite();tempType
Resources.Load(&spriteName&,tempType.getType()) as S这样就可以添加Sprite了
Texture2D texture = new Texture2D(1,1);
(texture);
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
spriteRenderer.sprite =
如果需要动态更新,又要使用Sprite Packer,最好的解决方案是用AssetBundle,将你需要Sprite Packer到一起的Sprites打入同一个Assetbundle中。更新的时候只需要更新这个Assetbundle即可。加载:WWW www = new WWW(&your assetbundle path&);AssetBundle assetBundle = Sprite sprite = assetBundle.LoadAsset&Sprite&(&spriteName&);或者Sprite[] sprites = assetBundle.LoadAllAsset&Sprite&();NOTE: Sprite can NOT use LoadAsync
我想问下,要是我想把手机相册里面的图片替换为unity中image,这个我应该怎么做
楼主问题解决了么~
坟贴了还一直有人挖,我就共享下我目前的解决方法吧:移动端:AssetBundle,不需要Resource.Load。方法7楼讲了。电脑端:用AssetBundle不方便电脑制作和调试。因为是编辑器可以用编辑器的方法加载图片:UnityEditor.AssetDatabase.LoadAssetAtPath&Sprite&()如果又不想用AssetBundle,还想用SpritePacker。我知道的,只能Prefab关联。
PC网站+wap网站+微网站;一站式服务
我也来挖下。可以脚本序列化不更新的ui到resources 其他ab
首先把resource里面图片转化成sprite,private Image ImageS public List&Sprite& SpriteF然后在awake方法里面 void Awake()
ImageSource = GetComponent&Image&();
for (int i = 0; i & 120; i++)
Sprite tex = new Sprite();
tex = Resources.Load(&image/Comp 1_& + i,typeof(Sprite)) as S
Debug.Log(tex.name);
SpriteFrames.Add(tex);
Debug.Log(SpriteFrames.Count);
登录百度帐号推荐应用Html5添加canvas图像导出为多种格式图片的jQuery插件教程 - 开源中国社区
当前访客身份:游客 [
当前位置:
发布于 日 16时,
多米移动广告是整合admob广告、iad、mmedia、广点通、百度广告、adcolony视频广告等广告平台的移动广告优化工具,帮助开发者提高广告收入。
代码片段(1)
1.&[代码][HTML]代码&&&&
一、使用方法
在页面中引入jQuery和export-canvas.js文件。
&script src="jquery.min.js"&&/script&
&script src="js/export-canvas.js"&&/script&
二、导出图片
var exampleCanvasID = "myCanvas";
var exportCanvas = new ExportCanvas();
exportCanvas.loadConfigFile("core/config/config.js");
exportCanvas.loadLanguageFile("core/language/de.js");
exportCanvas.setMimeType("image/jpeg");
exportCanvas.setExportQuality(1.0);
exportCanvas.export(exampleCanvasID, function() {
}, function(getLastReport) {
exportCanvas.export(exampleCanvasID);
window.onload = function() {
exportCanvas.export(exampleCanvasID);
插件中提供了两种语言:德语和英语。可以通过.loadLanguageFile()方法来切换。setMimeType()方法用于设置导出图片的类型。setExportQuality()是导出图片的质量,取值在0.1-1.0之间。最后可以使用export方法来导出图片。
多米移动广告是整合admob广告、iad、mmedia、广点通、百度广告、adcolony视频广告等广告平台的移动广告优化工具,帮助开发者提高广告收入。
开源中国-程序员在线工具:
相关的代码(227)
开源从代码分享开始
大街小巷的其它代码

我要回帖

更多关于 unity中resources加载 的文章

 

随机推荐