Author Topic: Best way to set up colored grid of letters?  (Read 4808 times)

dppc

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Best way to set up colored grid of letters?
« on: August 21, 2015, 03:40:49 PM »
I want to create a 10x10 grid of square cells. Each cell contains a letter and background color.

So, I created a GameObject called "Grid" with a UIGrid component attached to it.
I then created a GameObject called "Cell" with 2 children: a UILabel to hold the letter and a UISprite for the background color.
I added 100 of those "Cells" to the "Grid."

Is this the best way to do this with NGUI?
Should the "Grid" or "Cell" have a UIWidget component attached?
Is the UISprite necessary for the background color? Or is there a better way?

Thanks in advance for helping a beginner!

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Re: Best way to set up colored grid of letters?
« Reply #1 on: August 21, 2015, 07:15:35 PM »
When creating a sprite or label you generally do not need to worry about UIWidgets, since every sprite, label, etc already have a UIWidget component included.
For the cell: I would create a new UIWidget and use it as a base for the cell and then add a UISprite and UILabel as children. If you do not have any performance issues having a simple sprite with one color as a background should be fine. If you make the sprite texture white, you can color it using the sprite settings and do not need differently colored sprites.

I would probably have a setup like this:

+ GameObject with UIGrid component
-+UIWidget(your cell object)
--+UISprite (background color)
--+UILabel