iLMS知識社群歷程檔Login
Position: 黃國哲 > Unity
1090405 在Unity裡面開啟外部圖片
by 黃國哲 2020-04-05 19:40:38, Reply(0), Views(618)





第一階段:

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;
}
}



Reply