我在 YouTube 上找到了一个教程,该教程使用 Unity 2017.3.1f1 准确地将文件资源管理器和图像上传到画布上的“RawImage”。
我要做的是在“按下按钮”后将相同的图像添加到 3D 对象,如彩色立方体所示的立方体或平面。当我运行以下代码时,它注册为存在于多维数据集上但不呈现。任何帮助表示赞赏。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
public class Explorer : MonoBehaviour
{
string path;
public RawImage image;
public void OpenExplorer()
{
path = EditorUtility.OpenFilePanel("Overwrite with png", "", "png");
GetImage();
}
void GetImage()
{
if (path != null)
{
UpdateImage();
}
}
void UpdateImage()
{
WWW www = new WWW("file:///" + path);
image.texture = www.texture;
}
}