- Home /
 
               Question by 
               unity_rlFLvf0uW7IAgg · Mar 21, 2018 at 11:22 AM · 
                c#texturetexture2d  
              
 
              Problem when loading texture from folder
I try to load texture from a folder with the following script.
 using System.IO;
 using System.Collections;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class LoadImage : MonoBehaviour {
     public RawImage texturePreview;
 
     IEnumerator Start () {
         byte[] fileData = File.ReadAllBytes ("C:/Users/Public/Pictures/ScanImage.jpg");
         yield return new WaitForEndOfFrame ();
         Texture2D rawTexture = new Texture2D (2, 2);
         rawTexture.LoadImage (fileData);
         texturePreview.texture = rawTexture;
     }
 }
It seems works. However, I find that the texture load with script have a big different comparing with I just import a texture in a asset folder.
Below video show a texture loaded from a folder with above script. When I drag a same texture form assets folder, the texture become different.
Anyone know what is the problem and how to fix it?
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                