- Home /
BoxCollider2D.size is not a member of Collider2D.
The problem is that the unity manual says to change the size of a box collider you have to go and set the .size of the object. Apparently unity dose not have this as a member of Collider2D. Is this a bug with a unity 5.4 Build or am i doing this wrong.
The .size gets highlighted in red in mono develop.
Coll2 = Building[Item].GetComponent <BoxCollider2D> ();
Spr2 = Building[Item].GetComponent <SpriteRenderer> ();
Spr.sprite = Spr2.sprite;
Coll2.size = Coll.size;
Answer by MelvMay · Apr 07, 2016 at 12:40 PM
You don't specify what you've defined 'Coll2' as. If it's of type Collider2D then it won't work as Collider2D doesn't have a 'size' property. Define it as BoxCollider2D then it'll obviously have that property.
Funny how you think this could be a bug in Unity. ;)
I was using the unity 5.4 beta build and they can have some strange bugs sometimes.
Yeah, certainly there are bugs but that would be a huge one and completely break Unity, :)
Anyway, glad you got it working and good luck with your project!
Your answer