- Home /
[PUN] I want people to see my GUI
so what i am trying to achieve is when i press escape it doesn't open the other players GUI just mine, but the other players can see my GUI, i am using 4.6 world space gui.
i can open my gui but they dont see it at the moment.
@Landern It's pretty obvious what he wants. Goal: He hits the escape key, it opens his gui, and other players should be able to see it.
What he has currently: He can open his gui, but the other players don't see it.
Are you using RPC calls and unity NetworkView's?
If you are and because you have given nothing to work with... i can only speak in concepts.
You would want prefabs for your menus. The menu's options and what have you would be referenced from the players gameobject or from a manager of some sort.
If the $$anonymous$$enu is yours, then you display it(assu$$anonymous$$g the positions are updated for the current users screen). If the menu is not yours, it should assume the transform/position close to the player on screen.
As a user transverses the menu, these changes to the state need to be sent to the appropriate player(s).
Again not knowing if this is a network thing... can't get more specific and you're not sharing your not as designed code/scripting which is not helpful, no screenshots, nothing.
sorry i was at an internet cafe at the time i posted this, this is a picture of what i have at the moment...
and what i need is the guest2581 to see that guest1727 is in his menu.
i am using the Pun network and unitys 4.6 gui worldspace.
the code is this to show the menu.
public class animation : Photon.$$anonymous$$onoBehaviour {
public GameObject player;
public GameObject right_arm;
public GameObject camera_1;
public Canvas canvass;
private $$anonymous$$enu_right mR;
private $$anonymous$$ouseLook mL;
private bool ll = false;
private bool rr = false;
private bool cursorL = true;
Animator anim;
Rigidbody body;
PhotonView pv;
void Start ()
{
pv = player.GetComponent <PhotonView> ();
body = player.GetComponent<Rigidbody> ();
mR = right_arm.GetComponent ("$$anonymous$$enu_right") as $$anonymous$$enu_right;
mL = camera_1.GetComponent ("$$anonymous$$ouseLook") as $$anonymous$$ouseLook;
anim = GetComponent<Animator> ();
}
void Update ()
{
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Escape)) {
if (mR.$$anonymous$$enu == true) {
if (pv.is$$anonymous$$ine){
mR.$$anonymous$$enu = false;
mL.enabled = true;
cursorL = true;
Screen.showCursor = false;
anim.SetBool ("$$anonymous$$enu", false);
canvass.enabled = false;
}
else {canvass.enabled = true;}
} else {
if (pv.is$$anonymous$$ine){
mR.$$anonymous$$enu = true;
mL.enabled = false;
cursorL = false;
Screen.showCursor = true;
anim.SetBool ("$$anonymous$$enu", true);
canvass.enabled = true;
}
else {canvass.enabled = false;}
}
}
}
Answer by Tricky7991 · Sep 12, 2014 at 10:40 PM
Hey,
I've seen some games with what you want. There is a couple ways to do this that I can think of. I kind of touched on one already which I will explain more on.
Basically it would be easier to make something to appear as the menu then to be a actual GUI. If you want to do a real GUI it would take some work but can be done. In a very similar way that I have made here.
In the screenshot, I have a cube scaled and a texture of a GUI on it. No real GUI.
The way I have made here is pretty straight forward. And you could change it to anything that you would want.
public bool menuTT = false;
public GameObject menuGUI;
void Start () {
menuGUI.SetActive(false);
}
void Update (){
if (networkView.isMine && Input.GetKeyUp (KeyCode.N) && menuTT == true){
menuTT = false;
networkView.RPC("Menufl", RPCMode.OthersBuffered, menuTT);
}
if (networkView.isMine && Input.GetKeyUp (KeyCode.M) && menuTT == false) {
menuTT = true;
networkView.RPC("Menutr", RPCMode.OthersBuffered, menuTT);
}
if (menuTT == true && networkView.isMine){
menuGUI.SetActive(true);
}
if (menuTT == false && networkView.isMine){
menuGUI.SetActive(false);
}
}
[RPC]
void Menutr(bool menuTT)
{
menuGUI.SetActive(true);
}
[RPC]
void Menufl(bool menuTT)
{
menuGUI.SetActive(false);
}
It works 100% tested it. You have to change it over to Photon's Networking though since its just using Unity's networking.
Answer by killa247 · Sep 12, 2014 at 11:20 PM
thanks, but ive done mine a slightly different way, both work i assume, just on your one, if a player had a gui opened if a player connected they wouldnt see if it was open or not (i think), anywhoo i cant up load the code because its too large, so heres the link on gist: link text
No problem, Yeah from what I saw of yours it should work. And yes $$anonymous$$e isn't buffered so it wouldn't appear for people connecting while its open. But I changed the script to fix that now. And it would be easy to fix that to have it work with the actual GUI and have the everything appear as it is on the other players.
Glad you were able to get it working though :) Watched the videos of you're game on youtube. It is looking pretty good! I'll keep my eye on it :D