Hello Guest

Author Topic: Centralising prefabs  (Read 3218 times)

mygamingproject

  • Newbie
  • *
  • Posts: 37
    • View Profile
Centralising prefabs
« on: December 27, 2014, 09:49:25 am »
I'm creating a 9x9 grid (think Match3 genre) and use a tile/square as a prefab which has all its characteristics. 

I generate columns and rows and then add prefabs to scene at runtime.

However, I want the alignment to be centralised to the screen for the purposes of resolution but not sure what the best way is to offset.  Do I add my tiles to a parent gameobject and centralise that GO to screen? Or do I work out the minus offset for x and y and start my tile building appropriately so 4.5 tile is the central position?

I kind of have the latter working but seems suboptimal.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Centralising prefabs
« Reply #1 on: December 27, 2014, 11:49:24 am »
The first sounds like the most sensible thing to do here, just calculate the position on one of them and everything else is relative to it. At the end of the day its just 9x9, i.e. 81 unique positions, you can precalculate that on startup and be done with it...

mygamingproject

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Centralising prefabs
« Reply #2 on: December 27, 2014, 01:13:08 pm »
Would you not have a parent gameobject and just move that like a container?