Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class TestScript : MonoBehaviour {
- public GUIStyle style;
- private const int MAX_ROWS = 16;
- private const int MAX_COLUMNS = 8;
- private const int BUTTON_WIDTH = 100;
- private const int BUTTON_HEIGHT = 50;
- void OnGUI() {
- GUI.skin.button = style;
- for (int row = 0; row < MAX_ROWS; row++) {
- for (int coloumn = 0; coloumn < MAX_COLUMNS; coloumn++) {
- int clicked = row * MAX_COLUMNS + coloumn;
- GUI.color = (clicked % 2 == 0) ? Color.red : Color.green;
- if (GUI.Button(new Rect(100 + (coloumn * BUTTON_WIDTH), 100 + (row * BUTTON_HEIGHT), BUTTON_WIDTH, BUTTON_HEIGHT), "Click Me!"))
- Debug.Log("Geklickt:" + (clicked));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement