Hello and thank you,
When I used to program in XNA in 2d,I could draw an image using a rectangle with the inputs of x, y, height, width.
Now, using unity, if I shrink the Y scale, it takes pixels off both sides of the object. This makes the object appear to raise up.
Is there a way to shrink an object, but just from the top?
using UnityEngine;
using System.Collections;
public class Turn : MonoBehaviour
{
float mfX;
float mfY;
// Use this for initialization
void Start ()
{
mfX = transform.position.x - transform.localScale.x/2.0f;
mfY = transform.position.y - transform.localScale.y/2.0f;
}
// Update is called once per frame
void Update ()
{
if(Input.GetMouseButton(0))
{
Vector3 v3Scale = transform.localScale;
transform.localScale = new Vector3(v3Scale.x + 0.1f , v3Scale.y + 0.1f , v3Scale.z);
transform.position = new Vector3(mfX + transform.localScale.x / 2.0f, mfY + transform.localScale.y / 2.0f , 0);
}
}
}
Add this script to your object and press mouse left button and you will get what ever you want. You can change this according to your requirements. I hope this would help you…