c# - Getting height/width from a unity gameobject -


i'm working on version of conway's game of life in unity, , here setup making grid:

i've created prefab of individual cell responding mouse click basis creating cell grid. have empty gameobject act controller create grid. i'm putting in code controller so, pointing prefab field:

[serializefield] private gameobject cell;  private camera _camera; 

my idea dimensions of cell , instantiate grid, _camera pointing main camera boundaries. however, i'm not sure how height/width gameobject. what's best way find out?

i don't know if found answer, common way using collider (if have one, mouse click needs it) or renderer (if have mesh) using:

getcomponent<collider>().bounds.size getcomponent<renderer>().bounds.size 

game of life nice, i've written paper bachelor seminar it. have fun!


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -