话不多说,直接上代码。
public class CubeScale : MonoBehaviour {
private Vector3 MousePos;private float LastCubeScale=1.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
MousePos = Input.mousePosition;
transform.position = Camera.main.ScreenToWorldPoint(MousePos + new Vector3(0, 0, 10));
if (Input.GetAxis("Mouse ScrollWheel")>0)
{
LastCubeScale += 0.05f;
}
else if (Input.GetAxis("Mouse ScrollWheel") < 0)
{
LastCubeScale -= 0.05f;
}
transform.localScale = Vector3.one * LastCubeScale;
}
}