private IEnumerator LoadImage(string path, MeshRenderer output) { var url = "file://" + path; var www = new WWW(url); yield return www; var texture = www.texture; if (texture == null) { Debug.LogError("Failed to load texture url:" + url); } output.material.mainTexture = texture; }
if (!File.Exists(filepath)) { Debug.LogError($"File not exists {filepath}"); return; } var x = new Texture2D(200, 200); if (!x.LoadImage(File.ReadAllBytes(filepath))) { Debug.LogError($"Load image failed"); return; } rawImage.texture = x;