daily pastebin goal
39%
SHARE
TWEET

Photon Bolt EnableLanBroadcast

a guest Jul 10th, 2018 259 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2.  
  3. public class Menu : Bolt.GlobalEventListener
  4. {
  5.     void OnGUI()
  6.     {
  7.         GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));
  8.  
  9.         if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
  10.         {
  11.             BoltLauncher.StartServer();
  12.         }
  13.  
  14.         if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
  15.         {
  16.             BoltLauncher.StartClient();
  17.         }
  18.  
  19.         GUILayout.EndArea();
  20.     }
  21.  
  22.     bool clientStarted = false;
  23.  
  24.     public override void BoltStartDone()
  25.     {
  26.         BoltNetwork.EnableLanBroadcast();
  27.  
  28.         if (BoltNetwork.isServer)
  29.         {
  30.             BoltNetwork.LoadScene("Bolt Game World");
  31.         }
  32.         else
  33.         {
  34.             clientStarted = true;
  35.         }
  36.     }
  37.  
  38.     void Update()
  39.     {
  40.         if (clientStarted && !BoltNetwork.isConnected)
  41.         {
  42.             foreach (var session in BoltNetwork.SessionList)
  43.             {
  44.                 BoltNetwork.Connect(session.Value.LanEndPoint);
  45.                 break;
  46.             }
  47.         }
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top