사용자가 이미지를 올리면 자동으로 저장되고 

앱을 재실행하면 이미지를 불러오는건데 

재실행할때 왜 안 뜰까? 


코드에 문제 있는지좀;

 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;

using System.IO;


public class LoadGallery : MonoBehaviour

       public RawImage img;


    void Start()

    {

        if (File.Exists(Application.persistentDataPath + "/Image"))

        {

            File.ReadAllBytes(Application.persistentDataPath + "/Image" + "/저장.jpg");

        }

    }


    public void OnClickImageLoad()

    {


        NativeGallery.GetImageFromGallery((file) => 

        {

            FileInfo seleted = new FileInfo(file);

            if(seleted.Length > 100000000)

            {

                return;

            }


            if(!string.IsNullOrEmpty(file))

            {

                StartCoroutine(LoadImage(file));

            }

        });

    }



    IEnumerator LoadImage(string path)

    {

        yield return null;


        byte[] fileData = File.ReadAllBytes(path);

        string filename = Path.GetFileName(path).Split('.')[0];

        string name = "저장";

        string savePath = Application.persistentDataPath + "/Image";

        if(Directory.Exists(savePath))

        {

            Directory.CreateDirectory(savePath);

        }


        File.WriteAllBytes(savePath + name + ".jpg",fileData);


        var temp = File.ReadAllBytes(savePath + filename + ".jpg");

        Texture2D tex = new Texture2D(0,0 );

        tex.LoadImage(temp);


        img.texture = tex;

        img.SetNativeSize();

        ImageSizeSetting(img, 1000, 1000);


    }

    void ImageSizeSetting(RawImage img , float x, float y)

    {

        var imgX = img.rectTransform.sizeDelta.x;

        var imgY = img.rectTransform.sizeDelta.y;


        if( x / y > imgX / imgY)

        {

            img.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,y);

            img.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,imgX *(y/imgY));

        }

        else

        {

            img.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, y);

            img.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, imgX * (y / imgX));

        }

    }


}