JMcc020

Unty3D动态加载图片

试验动态加载图片,代码如下:

using UnityEngine;
using System.Collections;

public class DynamicLoad : MonoBehaviour
{
    Texture2D txt;

    IEnumerator Start()
    {
        string path = Application.dataPath + "/Title000.png";
        WWW www = new WWW("file://" + path);
        yield return www;
        
        txt = new Texture2D(200,200);
        txt = www.texture; // 方式一
        //www.LoadImageIntoTexture(txt); // 方式二

    }

    void OnGUI()
    {
        if (txt != null)
        {
            GUI.DrawTexture(new Rect(0, 0, 200, 200), txt);
        }
    }
}

 

分类:

技术点:

相关文章:

  • 2021-11-26
  • 2021-12-03
  • 2021-09-27
  • 2022-01-07
  • 2021-11-19
  • 2021-09-20
  • 2022-01-02
  • 2021-10-18
猜你喜欢
  • 2022-01-01
  • 2017-12-05
  • 2021-11-19
  • 2021-08-15
  • 2018-05-03
  • 2021-11-11
  • 2020-06-14
相关资源
相似解决方案