For my 2D Game; I have a panel with an image Component (with a sprite) and a GridLayout component. On the panel i have also put a script that creates buttons for the panel (as children)
public void InitializeGrid(int rows, int columns, List<RbzFilteredWord> words)
{
RectTransform myRect = GetComponent<RectTransform>();
buttonHeight = myRect.rect.height / (float)rows;
buttonWidth = myRect.rect.width / (float)columns;
GridLayoutGroup grid = this.GetComponent<GridLayoutGroup>();
grid.cellSize = new Vector2(buttonWidth, buttonHeight);
...
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
button = (Button)Instantiate(prefab);
button.transform.SetParent(transform, false);
...
}
Problem:
The text of each button must indicate the color of the pixel (from the underlying image) at the pivot location of that button
I know that this method is available: GetPixel(x,y), but i don't know which coordinates i need to use as parameters for this method, since i'm a noob at unity