- Home /
Photon - Show player names.
Basically im using the photon unity plug in and im trying to get it to get it to show the player names but it keeps showing them in one place, why?
heres my code:
public class PlayersInRoom : MonoBehaviour {
public ArrayList ListOFPlayers=new ArrayList();
public float Movedown;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
foreach(PhotonPlayer pl in PhotonNetwork.playerList )
{
foreach(string player in ListOFPlayers)
{
if (player!=pl.name)
{
ListOFPlayers.Add(pl.name);
}
}
if((ListOFPlayers.IndexOf(pl.name) % 1)>0)
{
Debug.Log((ListOFPlayers.IndexOf(pl.name)));
if(GUI.Button(new Rect(0,(ListOFPlayers.IndexOf(PhotonNetwork.player.name)*100)+100,100,100),pl.name))
{
}
}
else
{
Debug.Log((ListOFPlayers.IndexOf(pl.name)));
if(GUI.Button(new Rect(400,(ListOFPlayers.IndexOf(PhotonNetwork.player.name)*100)+100,100,100),pl.name))
{
}
}
}
}
}
Comment
Answer by skylem · Feb 21, 2015 at 05:19 PM
use GUILayout to spread multiple GUI over a setable area u can set the areas with
BeginArea(dimensions);
BeginHorizontal();
BeginVertical();
display here
EndHorizontal();
EndVertical();
EndArea();
or alternatively move the GUI that displays them into a foreach and multiply the index value by an offset value.
int index = IndexOf(pl.name);
int offset = 100;
foreach(string player in ListOFPlayers)
{
GUI.Box(new Rect(400, index * offset + 10,25,100),pl.name);
}
Your answer
Follow this Question
Related Questions
GUI issues 1 Answer
How to display player coins on multiplayer 1 Answer
Photon - Distinguishing player types for spawns 0 Answers
scoreboard for multiplayer game 0 Answers
How to get LocalPlayer position in Photon Bootcamp Demo? 1 Answer