File size: 389 Bytes
3868539 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
using System;
using UnityEngine;
public class ImagePreview : MonoBehaviour
{
public GameObject imageQuad;
public void SetTexture(Texture texture)
{
imageQuad.GetComponent<MeshRenderer>().material.mainTexture = texture;
var aspectRatio = texture.width / (float)texture.height;
imageQuad.transform.localScale = new Vector3(aspectRatio, 1f, 1f);
}
}
|