Search Unity

GUI inside a While Loop

Discussion in 'Immediate Mode GUI (IMGUI)' started by JakeLeB, Mar 27, 2015.

  1. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    I have two Floats, yOffset and playerCount. I'm using PUN and trying to give a HUD for each player joined. But it seems to be putting all of the HUDs at exactly the same height... I thought if I had a while loop that checks if the current rooms player count is higher than the float I created and added to the float after running the DrawTexture it would put them at different heights, but I can't seem to figure this out and would really appreciate some help.

    while (PhotonNetwork.room.playerCount > playerCount) {
    foreach (PhotonPlayer player in PhotonNetwork.playerList) {
    GUI.DrawTexture (new Rect (355, yOffset, 100, 50), HealthBar);
    }
    if(playerCount != PhotonNetwork.room.playerCount) {
    yOffset += 45;
    playerCount += 1;
    }
    }