iLMS知識社群歷程檔登入
位置: 黃國哲 > Unity
1090405 在Unity裡面開啟外部圖片
by 黃國哲 2020-04-05 19:40:38, 回應(0), 人氣(739)





第一階段:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;

public class FileManager : MonoBehaviour
{
string path;
public RawImage image;

public void OpenExplorer()
{
path = EditorUtility.OpenFilePanel("Overwrite with png","","png");
}

}


///////////////////////////////////////////////


第二階段:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;

public class FileManager : 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;
}
}



回應