unity上传头像_unity3d 上传本地PC图片

网上有两个常用的方法,我先用了第一种。

第一种方法:

需要注意三点,首先导入system.window.Forms.dll库,导进去后一定记得要修改playersetting下的optimization->API compatibility level为.NET 2.0,至于为什么改成这样,可以参考unity3d 的解释:http://game.ceeger.com/Manual/MobileDotnet.html。

还要注意一点:加载的本地图片地址一定不能带有中文路径

另外,www新建的时候要加上“file://” + url;

WWW www = new WWW("file://" + url); //注意要加上"file://"

只需要一个脚本,其中代码如下:

using UnityEngine;

using System.Collections;

using System.Windows.Forms;

using System.IO;

public class UploadImg: MonoBehaviour {

public Texture2D img = null;

void OnGUI()

{

if (GUI.Button(new Rect(0, 0, 100, 20), "选择文件"))

{

OpenFileDialog od = new OpenFileDialog();

od.Title = "请选择头像图片";

od.Mult

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值