/// <summary> /// This Unity window wraps up buttons for additional feature showcases. As such they /// would not be part of a regular game. /// </summary> /// <param name="id">the window's id. we only use one window.</param> private void OnGUIWindowOptions(int id) { GUILayout.BeginArea(new Rect(2, 20, Screen.width / 3, Screen.height / 3)); if (GUILayout.Button("Close Options")) { this.showOptions = false; } // This button controls the encryption showcase. First off, encryption keys must be exchanged. if (!this.GameInstance.PeerIsEncryptionAvailable) { if (GUILayout.Button("Encryption: Exchange keys")) { this.GameInstance.OpExchangeKeysForEncryption(); } } else { // After encryption keys were exchanged, you can use encryption. As demo, this is used on positon data. if (GUILayout.Button(Game.RaiseEncrypted ? "Enrcyption: Dont" : "Encryption: Do use")) { Game.RaiseEncrypted = !Game.RaiseEncrypted; } } // Toggle between reliable and unreliable sending of the position updates. if (GUILayout.Button(Player.isSendReliable ? "Send pos unreliable" : "Send pos reliable")) { Player.isSendReliable = !Player.isSendReliable; } // Toggle visibility of PhotonStatsGui PhotonNetSimSettingsGui pnssg = FindObjectOfType(typeof(PhotonNetSimSettingsGui)) as PhotonNetSimSettingsGui; // better cache this to avoid Find if (pnssg != null && GUILayout.Button(pnssg.Visible ? "Hide Network Simulation Settings" : "Show Network Simulation Settings")) { pnssg.Visible = !pnssg.Visible; } // Toggle visibility of PhotonNetSimSettingsGui PhotonStatsGui psg = FindObjectOfType(typeof(PhotonStatsGui)) as PhotonStatsGui; // better cache this to avoid Find if (psg != null && GUILayout.Button(psg.Visible ? "Hide Photon statistics" : "Show Photon statistics")) { psg.Visible = !psg.Visible; } GUILayout.EndArea(); }
/// <summary>The "helper" gui scripts need to knwo the peer, so we set them. This is optional.</summary> public void SetPeerForGuiElements() { PhotonNetSimSettingsGui pnssg = FindObjectOfType(typeof(PhotonNetSimSettingsGui)) as PhotonNetSimSettingsGui; if (pnssg != null) { pnssg.Peer = this.Peer; } PhotonStatsGui psg = FindObjectOfType(typeof(PhotonStatsGui)) as PhotonStatsGui; if (psg != null) { psg.Peer = this.Peer; } }