赞
踩
<p><wbr>//加载图片方式1;(图片要放入在Assets/Resources/目录下); <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></p>Texture2D _tex = (Texture2D)Resources.Load("Lighthouse");
//加载图片方式2;(可以加载网络服务器和本地图片);
string filePath = "file://" + Application.dataPath +@"/_Image/grid.png";
WWW www = new WWW(filePath);
yield return www ;
Assets/_Script/AddObjBtnEvent.cs(57,20): error CS0234: The typeor namespace name `Drawing' does not exist in the namespace`System'. Are you missing an assembly reference? 解决方法之一: D:\ProgramFiles\Unity\Editor\Data\Mono\lib\mono\2.0\System.Drawing.dll将此路径下的System.Drawing.dll拖入到Project面板层次下,即可编译通过。 //加载图片方式3; filePath = Application.dataPath + @"/_Image/grid.png"; FileStream fs = newFileStream(filePath,FileMode.Open,FileAccess.Read); System.Drawing.Image img =System.Drawing.Image.FromStream(fs); //System.Drawing.Image.FromFile(filePath); //方法二加载图片方式。 MemoryStream ms = new MemoryStream(); img.Save(ms,System.Drawing.Imaging.ImageFormat.Png); Texture2D _tex2 = new Texture2D(128, 128); _tex2.LoadImage(ms.ToArray()); //此处为GameObject的材质类附上读取的纹理; _newObj.renderer.material.mainTexture = _tex2;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。