Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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;
                            y++;    
                    } else {
                            x++;
                    }
                    //go to next item 
                    buttonIndex ++;

            }
    }
share|improve this question

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.

share|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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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