Closed young-j-park closed 1 year ago
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class LoadIMGLocal : MonoBehaviour { GameObject image; string filename = "C:\\Users\\yjpar\\2.12-Hololens2\\img\\ur5_force.png"; void Start() { var rawData = System.IO.File.ReadAllBytes(filename); Texture2D tex = new Texture2D(2, 2); // Create an empty Texture; size doesn't matter (she said) tex.LoadImage(rawData); image = GameObject.Find("RawImage2"); image.GetComponent<RawImage>().texture = tex; } void Update() { Texture2D tex = new Texture2D(2, 2); // Create an empty Texture; size doesn't matter (she said) try { var rawData = System.IO.File.ReadAllBytes(filename); tex.LoadImage(rawData); image.GetComponent<RawImage>().texture = tex; } catch { print("Failed to load image."); } } }