728x90
728x170

 

 

    public Image image;

 

    void Start()

    {

        LoadImage(FilePath);

    }

 

    private void LoadImage(string path)

    {

        byte[] byteTexture = System.IO.File.ReadAllBytes(path);

        Texture2D texture = new Texture2D(0, 0);

        texture.LoadImage(byteTexture);

 

        Rect rect = new Rect(0, 0, texture.width, texture.height);

        image.sprite = Sprite.Create(texture, rect, new Vector2(0.5f, 0.5f));

    }

 

 

image 변수에 Image 를 할당해 주면 그곳에 경로의 이미지가 나타나게된다.

728x90
그리드형
Posted by kjun
,