博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Xlua开发笔记:网络图片加载
阅读量:3787 次
发布时间:2019-05-22

本文共 1003 字,大约阅读时间需要 3 分钟。

网络图片加载

较低版本unity加载网络图片,unity5.x及以下

function loadWebImage(url)	-- 获取imageView对象,imageView对象包含了RawImage组件    local imageView = GameObject.Find(“ImageView”)    local texture    local www    www = CS.UnityEngine.WWW(url)    while (true)    do        if www.isDone==true then            texture = www.texture            imageView:GetComponent("RawImage").texture = texture            break        end    endend

较高版本unity加载网络图片,unity2017以及之上

function loadWebImage(url)	-- 获取imageView对象,imageView对象包含了RawImage组件    local imageView = GameObject.Find("ImageView")    local texture = CS.UnityEngine.Texture2D(200, 100)     local www    www = CS.UnityEngine.Networking.UnityWebRequest.Get(url)    www:SendWebRequest()    while (true)    do        if www.isDone==true then            local result = www.downloadHandler.data            CS.UnityEngine.ImageConversion.LoadImage(texture, result)            imageView:GetComponent("RawImage").texture = texture            break        end    endend

目前使用之上两个办法,后续有更新再更改。

转载地址:http://tdktn.baihongyu.com/

你可能感兴趣的文章
Linux 进程管理
查看>>
Vulmap的使用
查看>>
SPSS Modeler工具笔记
查看>>
逻辑题分享
查看>>
后端开发中常用的语言
查看>>
数学考试(牛客)
查看>>
Codeforces Round #697 (Div. 3)
查看>>
Codeforces Round #705 (Div. 2)
查看>>
2021-04-11
查看>>
迷宫(BFS)
查看>>
1816. 连通(BFS+DFS+并查集)
查看>>
2021省赛总结
查看>>
Codeforces Round #719 (Div. 3)
查看>>
3. Mybatis说明typeAliases
查看>>
4. Mybatis结果集映射ResultMap
查看>>
8. Mybatis动态SQL
查看>>
1. 我的第一个Spring程序
查看>>
2. Spring定义继承parent
查看>>
3. Spring基于构造函数的依赖注入
查看>>
4. Spring 基于设值函数的依赖注入set注入
查看>>