A size control add-on for UITween
🚧 Requires UITween 🚧
You can get it free here in the official unity store
This repository aims to add the possibility to animate the size of the object instead of the scale as default.

UITweenSize is not affiliated with, supported or endorsed by the UITween asset by Adi Zhavo
After importing the asset, modify the following scripts:
Add line 82
public void SetAnimationSize(Vector3 StartSize, Vector3 EndSize, AnimationCurve EntryTween, AnimationCurve ExitTween)
{
currentAnimationGoing.SetAnimationSize(StartSize, EndSize, EntryTween, ExitTween);
}Add line 22
private bool sizeEnabled;Add line 57
EditorSize();Modify line 83
if (positionEnabled || rotationEnabled || scaleEnabled || sizeEnabled || tweenScript.animationParts.FadePropetiesAnim.IsFadeEnabled()) ...Modify line 93
if (positionEnabled || rotationEnabled || scaleEnabled || sizeEnabled) ...Modify line 109
if (positionEnabled || rotationEnabled || scaleEnabled || sizeEnabled || tweenScript.animationParts.FadePropetiesAnim.IsFadeEnabled()) ...Add line 128
tweenScript.animationParts.SizePropetiesAnim.StartSize = selectedTransform.sizeDelta;Add line 138
tweenScript.animationParts.SizePropetiesAnim.EndSize = selectedTransform.sizeDelta;Add line 154
if (tweenScript.animationParts.SizePropetiesAnim.IsSizeEnabled())
selectedTransform.sizeDelta = tweenScript.animationParts.SizePropetiesAnim.StartSize;Add line 178
if (tweenScript.animationParts.SizePropetiesAnim.IsSizeEnabled())
selectedTransform.sizeDelta = tweenScript.animationParts.SizePropetiesAnim.EndSize;Add line 304
void EditorSize()
{
tweenScript.animationParts.SizePropetiesAnim.SetSizeEnable(EditorGUILayout.BeginToggleGroup("Size Animation",
tweenScript.animationParts.SizePropetiesAnim.IsSizeEnabled()));
sizeEnabled = tweenScript.animationParts.SizePropetiesAnim.IsSizeEnabled();
if (sizeEnabled)
{
tweenScript.animationParts.SizePropetiesAnim.StartSize = EditorGUILayout.Vector3Field("Start Size", tweenScript.animationParts.SizePropetiesAnim.StartSize);
tweenScript.animationParts.SizePropetiesAnim.EndSize = EditorGUILayout.Vector3Field("End Size", tweenScript.animationParts.SizePropetiesAnim.EndSize);
EditorGUILayout.BeginHorizontal();
if (tweenScript.animationParts.SizePropetiesAnim.TweenCurveEnterSize == null)
{
tweenScript.animationParts.SizePropetiesAnim.TweenCurveEnterSize = new AnimationCurve();
}
if (tweenScript.animationParts.SizePropetiesAnim.TweenCurveExitSize == null)
{
tweenScript.animationParts.SizePropetiesAnim.TweenCurveExitSize = new AnimationCurve();
}
tweenScript.animationParts.SizePropetiesAnim.TweenCurveEnterSize = EditorGUILayout.CurveField("Start Tween Size",
tweenScript.animationParts.ScalePropetiesAnim.TweenCurveEnterScale);
EditorGUILayout.Space();
tweenScript.animationParts.SizePropetiesAnim.TweenCurveExitSize = EditorGUILayout.CurveField("Exit Tween Size",
tweenScript.animationParts.SizePropetiesAnim.TweenCurveExitSize);
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
}
EditorGUILayout.EndToggleGroup();
}Add line 64
if (animationPart.SizePropetiesAnim.IsSizeEnabled())
{
SizeAnimation(rectTransform, percentage);
}Add line 147
if (animationPart.SizePropetiesAnim.IsSizeEnabled())
{
SetCurrentAnimSize(animationPart.SizePropetiesAnim.TweenCurveEnterSize,
animationPart.SizePropetiesAnim.StartSize,
animationPart.SizePropetiesAnim.EndSize);
}Add line 200
if (animationPart.SizePropetiesAnim.IsSizeEnabled())
{
SetCurrentAnimSize(animationPart.SizePropetiesAnim.TweenCurveExitSize,
animationPart.SizePropetiesAnim.EndSize,
animationPart.SizePropetiesAnim.StartSize);
}Add line 230
public void SetAnimationSize(Vector2 StartSize, Vector2 EndSize, AnimationCurve EntryTween, AnimationCurve ExitTween)
{
animationPart.SizePropetiesAnim.StartSize = StartSize;
animationPart.SizePropetiesAnim.SetSizeEnable(true);
animationPart.SizePropetiesAnim.EndSize = EndSize;
animationPart.SizePropetiesAnim.SetAnimationsCurve(EntryTween, ExitTween);
}Add line 303
#region SizeAnim
private AnimationCurve currentAnimationCurveSize;
private Vector3 currentStartSize;
private Vector3 currentEndSize;
public void SetCurrentAnimSize(AnimationCurve currentAnimationCurveSize, Vector3 currentStartSize, Vector3 currentEndSize)
{
this.currentAnimationCurveSize = currentAnimationCurveSize;
this.currentStartSize = currentStartSize;
this.currentEndSize = currentEndSize;
}
public void SizeAnimation(RectTransform _rectTransform, float _counterTween)
{
float evaluatedValue = currentAnimationCurveSize.Evaluate(_counterTween);
Vector3 valueAdded = (currentEndSize - currentStartSize) * evaluatedValue;
_rectTransform.sizeDelta = currentStartSize + valueAdded;
}
#endregionAdd line 521
[System.Serializable]
public class SizePropetiesAnim
{
#region SizeEditor
[SerializeField]
[HideInInspector]
private bool sizeEnabled;
public void SetSizeEnable(bool enabled)
{
sizeEnabled = enabled;
}
public bool IsSizeEnabled()
{
return sizeEnabled;
}
[HideInInspector]
public AnimationCurve TweenCurveEnterSize;
[HideInInspector]
public AnimationCurve TweenCurveExitSize;
[HideInInspector]
public Vector3 StartSize;
[HideInInspector]
public Vector3 EndSize;
public void SetAnimationsCurve(AnimationCurve EntryTween, AnimationCurve ExitTween)
{
TweenCurveEnterSize = EntryTween;
TweenCurveExitSize = ExitTween;
}
#endregion
}Add line 693
#region SizeEditor
[HideInInspector]
public SizePropetiesAnim SizePropetiesAnim = new SizePropetiesAnim();
#endregionUITweenSize is available under the MIT license. See the LICENSE file for more info.