I am sure that inventoryItem.Name contains "Wood" cause i see it when i add a breakpoint. Still i get nothing in the game. Just empty buttons.

void DrawInventoryContent (int id)
            var buttonIndex = 0;
            var x = 0;
            var y = 0;

            foreach (var item in inventoryItems) {
                    //create position rectangel for button
                    var startMargin = buttonMargin;
                    var leftStartPosition = startMargin + buttonMargin * x + buttonWidth * x; 
                    var topStartPosition = startMargin + buttonMargin * y + buttonHeight * y;
                    var buttonRectangel = new Rect (leftStartPosition, topStartPosition, buttonWidth, buttonHeight);

                    //Get inventoryiten by index
                    var inventoryItem = inventoryItems [buttonIndex];
                    var name = inventoryItem.Name;

                    //Create and place buttin
                    GUI.Button (buttonRectangel, name);

                    // check if this button is at end of row and change to next row
                    if (x == buttonsPerRow - 1) {
                            x = 0;
                    } else {
                    //go to next item 
                    buttonIndex ++;


2 Answers 2


I see a couple of potential problems. Ensure that GUI.Button is being called in OnGUI. Remember that you need to put GUI.Button in a conditional, otherwise you'll never know if someone clicks on it. Also check that you're using the appropriate GUI Style, perhaps the font size is tiny or the colour is the same as the background.


Sorry for taking up your time. The answer can be found here. http://answers.unity3d.com/questions/582692/string-on-guibutton-not-showned.html#answer-583425


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .