Unity Button Doesn't Work In Multiplayer

Options
Hi. For some reason, whenever I press a button when two people are connected, nothing happens (I mean nothing. No error, the button does nothing. It doesn't even freeze the game). When one person leaves, the button works perfectly fine. I don't even have the slightest idea why this would even happen. Can someone suggest what may be the problem? Thanks in advance! Here is my code if you need (This is only the method in which my button is in. I don't think the rest of the code is really needed, but if it is I'll post it): [code2=csharp]void DoMyWindow (int windowID) {

if(pv.isMine)
{

style.fontSize = 15;
GUI.Label (new Rect (10,20,200,100), currentWord, style);
if(GUI.Button(new Rect(200,50,100,20), buttonMessage)) //This button
{
attackButton++;
}
if(attackButton == 0)
{
currentWord = "What would you like to do?";
buttonMessage = "Attack";
}
else if(attackButton == 1)
{
Debug.Log(attackButton);
currentWord = "Which attack would you like to use?";
if(GUI.Button(new Rect(200,75,100,20), "Attack1"))
{
attackButton = attackButton + 2;
}
buttonMessage = "Attack2";
Debug.Log(currentWord);
}
else if(attackButton == 2)
{
Debug.Log(attackButton);
whichAttackUsing = "attack1";
attackName = "Attack1";
playerDamage = Random.Range(3,6);
photonView.RPC ("ReadyUp", PhotonTargets.Others);
StartCoroutine(Attack());
attackButton = 0;
}
else if(attackButton == 3)
{
Debug.Log(attackButton);
whichAttackUsing = "attack2";
attackName = "Attack2";
playerDamage = Random.Range(3,6);
photonView.RPC ("ReadyUp", PhotonTargets.Others);
StartCoroutine(Attack());
attackButton = 0;
}
}
}[/code2]

Comments

  • Tobias
    Options
    You check pv.isMine. If pv is the same GO on both clients, then it's only owned by one and false on the other. No buttons.
    I don't see what's failing.
  • The pv is different on each game object. The only reason I added the if(pv.isMine) statement is because if I don't have that, when I click the button, it says it attackButton = 1 in the debug log but it doesn't change the phrase or the button name unless one person leaves and the other presses the button. So in both cases, with pv.isMine and without it, the button doesn't work unless one person leaves. Also, when I say the button doesn't work, I mean on either client. Both clients see it also.
  • Tobias
    Options
    If the button is not working at all with or without the pv.isMine, you might want to ask in the Unity forum. If it's not reacting at all, then the networking issues you have are not the cause for it but a consequence.
    Sorry, can't try it at the moment...