Question by
skammamma · Mar 16, 2016 at 04:47 PM ·
mouse input
how to scale cube in game mode with mouse clicks??
hi friends i want to scale the cube in game mode with mouse clicks i.e., I want to increase and decrease the height of cube in game mode .....please help me out
Comment
Do you want to scale it by dragging or clicking a button or something. Please be more exact :)
Answer by ComradeVanti · Mar 19, 2016 at 01:53 PM
Well pretty much all you need is this:
using UnityEngine;
using System.Collections;
public class Click_Scaler : MonoBehaviour
{
public float scaleBy;
public Transform cubeTrans;
void OnMouseDown ()
{
cubeTrans.localScale.Scale (new Vector3 (scaleBy, scaleBy, scaleBy));
}
}
Add this to your button. "scaleBy" is the amount you want to scale it by on click.
"cubeTrans" is the Transform of your Cube object.
Good luck! :)