I can not figure out how to use them right.
I tried to follow your explanation and created this:
grid
= new GameObject
[width,height
];
for (int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
GameObject gridTile = NGUITools.AddChild(transform.gameObject, tile);
gridTile
.transform.localPosition = new Vector3
(gridTile
.transform.position.x + (362*x
-1),
gridTile.transform.position.y + (362*y-1),
gridTile.transform.position.z);
UIButton button
= new UIButton
(); button = gridTile.GetComponent<UIButton>();
EventDelegate.Set(button.onClick, Buttons.MakeItBlue);
grid[x,y] = gridTile;
}
}
But I get error messages:
error CS0120: An object reference is required to access non-static member `Buttons.MakeItBlue()'
error CS1502: The best overloaded method match for `EventDelegate.Set(System.Collections.Generic.List<EventDelegate>, EventDelegate)' has some invalid arguments
error CS1503: Argument `#2' cannot convert `object' expression to type `EventDelegate'
Obviously, I don't use the Snippets right and I can't figure out what could be wrong. For example, I looked the "object reference" error up, and what I found is not different from what I did:
UIButton button
= new UIButton
();button = gridTile.GetComponent<UIButton>();
I just don't know where to start debugging it, because I only understand the half of what is going on there and how to use the code.