怎么打开动态加载图片的读写权限
read/write Enable 无法在项目运行时更改
unity怎么读取动态加载的图片的像素颜色(急!!!另有一个同样问题80c,有用的一起给)
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- wjintao 2018-08-08 06:27关注
/// <summary> /// 以IO方式进行加载 /// </summary> private void LoadByIO() { string ImagePath = string.Format("{0}/{1}", Application.streamingAssetsPath, "Test.jpg"); Debug.LogFormat("ImagePath:{0}", ImagePath); //创建文件读取流 FileStream fileStream = new FileStream(ImagePath, FileMode.Open, FileAccess.Read); fileStream.Seek(0, SeekOrigin.Begin); //创建文件长度缓冲区 byte[] bytes = new byte[fileStream.Length]; //读取文件 fileStream.Read(bytes, 0, (int)fileStream.Length); //释放文件读取流 fileStream.Close(); fileStream.Dispose(); fileStream = null; //创建Texture int width = 300; int height = 372; Texture2D texture = new Texture2D(width, height); texture.LoadImage(bytes); Color[] colors = texture.GetPixels(); Debug.LogFormat("pixels:{0}", colors.Length); } 看看能不能帮到你
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 github符合条件20分钟秒到账,github空投 提供github账号可兑换💰感兴趣的可以找我交流一下
- ¥50 永磁型步进电机PID算法
- ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
- ¥88 找成都本地经验丰富懂小程序开发的技术大咖
- ¥15 如何处理复杂数据表格的除法运算
- ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
- ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
- ¥200 uniapp长期运行卡死问题解决
- ¥15 latex怎么处理论文引理引用参考文献
- ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?