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 ++;


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.

| improve this answer | |

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.