
Hello, I\'m using the new UI system from Unity 4.6 beta...
Tried diffe
Actuallly playing with following can help: GetComponent.sizeDelta = new Vector(new_size.x,new_size.y);
I successfully achieved Zooming in new GUI by setting this property.
Here is my own code for scaling:
void Start()
{
// Store initial Size and Position;
ZoomedOutSize = new Vector2(GetComponent().rect.width, GetComponent().rect.height);
ZoomedOutPos = new Vector2(GetComponent().localPosition.x, GetComponent().localPosition.y);
}
void Update()
{
// Calculate the total delta at runtime cause it depends on parent (yah i know it's not optimal to have new vector ecery Update)
ZoomSizeRate = new Vector2(gameObject.GetComponentInParent().MaxSize.x - ZoomedOutSize.x, gameObject.GetComponentInParent().MaxSize.y - ZoomedOutSize.y);
ZoomPosRate = -GetComponent().localPosition;
// Zoom is the float with range(0,1) 0 - no Zoom, 1 - Fully Zoom to ParentSize;
//Set the size delta and position as Initial + Rate * Zoom
GetComponent().sizeDelta = new Vector2(ZoomedOutSize.x + ZoomSizeRate.x * Zoom, ZoomedOutSize.y + ZoomSizeRate.y * Zoom);
GetComponent().localPosition = new Vector2(ZoomedOutPos.x + ZoomPosRate.x * Zoom, ZoomedOutPos.y + ZoomPosRate.y * Zoom);
}