- Home /
Question by
FlawlessDog · Jun 28, 2011 at 07:28 PM ·
texture2dscaleitween
Texture2D scale - iTween
How do I keep Texture2D scale the same(100% width/height) regardless of the width of Rect that is holding it?
I am using iTween to adjust the width of the rect, but I need the Texture2D scale to NOT be effected by this scaling. Example:
private var laserAnalysis01a : Rect = new Rect(245,40,0,376);
//
public var laserAnalysis01_pic_a : Texture2D;
//
private var la1On_a : Rect = new Rect(245,40,860,376);
//
function la1Trip_a()
{
iTween.ValueTo(gameObject,iTween.Hash("from",laserAnalysis01a.width,"to",la1On_a.width,"onupdate","la1Mo_a","easetype","easeOutQuint"));
}
//
function la1Mo_a(Scale:float)
{
laserAnalysis01a.width = Scale;
}
//
function OnGUI()
{
GUI.DrawTexture(laserAnalysis01a, laserAnalysis01_pic_a);
}
This scaling of the Rect with iTween works great except that the texture is scaled along with it, and I would like to avoid that.
Thanks in advance ^_^
Comment
Best Answer
Answer by FlawlessDog · Jun 28, 2011 at 09:23 PM
SUCCESS!! ^_~
Found me answer here. Bottom of page:
private var laserAnalysis01a : Rect = new Rect(0,0,860,376);
//
public var laserAnalysis01_pic_a : Texture2D;
//
private var la1On_a : Rect = new Rect(245,40,860,376);
//
private var laGroup1 : Rect = new Rect(245,40,0,376);
//
function la1Trip_a()
{
iTween.ValueTo(gameObject,iTween.Hash("from",laGroup1.width,"to",la1On_a.width,"onupdate","la1Mo_a","easetype","easeOutQuint"));
}
//
function la1Mo_a(Scale:float)
{
laGroup1.width = Scale;
}
//
function OnGUI()
{
GUI.BeginGroup( laGroup1 );
GUI.DrawTexture(laserAnalysis01a, laserAnalysis01_pic_a);
GUI.EndGroup();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612124638im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Scaling / Resizing an Image (Texture2D) 6 Answers
itweenpath scale and position 0 Answers
Scale GUI Texture From the Center. 1 Answer
iTween ScaleTo + gravity == halting falling motion 0 Answers