Help needed in unity..

Updated on September 6, 2017 in [A] C# .Net
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on September 5, 2017

Hello guys. I ma trying to do something in unity. I want to scale an object named wall when the Alphabet “G ” is pressed.

But this is the problem that i get.

This is the Script part:


this is the unity GUI part

The Selected one is the wall. If i use the GetComponent<Renderer>();    it workers  but it doesn’t works directly.




  • Liked by
3 on September 5, 2017

How about:

//create a new Vector3 that is the scale you desire
Vector3 scale = new Vector3 { x = 1, y = 1, z = 1 };
//set local scale to the Vector3
gameObject.transform.localScale = scale;
on September 6, 2017

Ah thanks.. i got it

on September 6, 2017

Why not do this for the new vector3?

Vector3 scale = new Vector3 (1, 1, 1);

Or even better:
Vector3 scale =;


on September 6, 2017

Yes i am now using that for the vector3 but now….Thanks

Show more replies
  • Liked by
0 on September 6, 2017

Perhaps they want to be specific about xyz values of the scale. The example was for clarity 😉

  • Liked by