Hi I am new bee in Unity and I am working on an app in which i want to load my Images in Aspect fit ratio on Texture. I Know that i can achieve this using ScaleMode.ScaleToFit but i am not getting this property in Texture 2d. I am doing following like this.
Texture2D tex = Resources.Load("ImageTargetTextures/WhatTheBuck/MYPicture") as Texture2D;
video.mIconPlane.renderer.material.mainTexture = tex;
video.mIconPlane.transform.rotation=Quaternion.AngleAxis(180, Vector3.up);
video.mIconPlane.transform.localScale = ScaleMode.ScaleToFit;
Video is the Object of my VideoClass and mIconPlane is public Game Object in Video Class. This will be great for me. Thanks in advance.
You can get a size of your image in pixels from one of public properties of
Texture2Dclass (can tell what exactly at the moment). Then, just setnew Vector3 (textureWidth/someValue, textureHeigth/someValue,1)tovideo.mIconPlane.transform.localScale.someValue– is some number to make your GameObject’s size as you whant. It depends onCamerasize.