using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class DemoTest : MonoBehaviour
{
string url = @"E:/simulator/Assets/Images/details/btn_go.png";
[SerializeField] private Image im;
// Start is called before the first frame update
void Start()
{
// Texture2D t = new Texture2D(1,1);
// t.LoadImage(ReadTexture(url));
// Sprite spr = Sprite.Create(t, new Rect(0,0,t.width,t.height), new Vector2(10.0f,10.0f));
// im.sprite = spr;
StartCoroutine(LoadTexture(url));
}
// Update is called once per frame
void Update()
{
}
#region 方法一:通过文件流(System.IO)的形式加载
/// <summary>
/// 文件路径
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
private byte[] ReadTexture(string path){
FileSt
Unity 加载图片的两种方式文件流和UnityWebRequest
最新推荐文章于 2024-07-06 09:37:51 发布

最低0.47元/天 解锁文章
757





