77
88namespace Bolt . Samples . GettingStarted
99{
10- public class Menu : Bolt . GlobalEventListener
11- {
12- bool ShowGui = true ;
10+ public class Menu : Bolt . GlobalEventListener
11+ {
12+ bool ShowGui = true ;
1313
14- private void Awake ( )
15- {
16- Application . targetFrameRate = 60 ;
17- BoltLauncher . SetUdpPlatform ( new PhotonPlatform ( ) ) ;
18- }
14+ private void Awake ( )
15+ {
16+ Application . targetFrameRate = 60 ;
17+ BoltLauncher . SetUdpPlatform ( new PhotonPlatform ( ) ) ;
18+ }
1919
20- void OnGUI ( )
21- {
22- if ( ! ShowGui ) { return ; }
20+ void OnGUI ( )
21+ {
22+ if ( ! ShowGui ) { return ; }
2323
24- GUILayout . BeginArea ( new Rect ( 10 , 10 , Screen . width - 20 , Screen . height - 20 ) ) ;
24+ GUILayout . BeginArea ( new Rect ( 10 , 10 , Screen . width - 20 , Screen . height - 20 ) ) ;
2525
26- if ( GUILayout . Button ( "Start Server" , GUILayout . ExpandWidth ( true ) , GUILayout . ExpandHeight ( true ) ) )
27- {
28- // START SERVER
29- BoltLauncher . StartServer ( ) ;
30- }
26+ if ( GUILayout . Button ( "Start Server" , GUILayout . ExpandWidth ( true ) , GUILayout . ExpandHeight ( true ) ) )
27+ {
28+ // START SERVER
29+ BoltLauncher . StartServer ( ) ;
30+ }
3131
32- if ( GUILayout . Button ( "Start Client" , GUILayout . ExpandWidth ( true ) , GUILayout . ExpandHeight ( true ) ) )
33- {
34- // START CLIENT
35- BoltLauncher . StartClient ( ) ;
36- }
32+ if ( GUILayout . Button ( "Start Client" , GUILayout . ExpandWidth ( true ) , GUILayout . ExpandHeight ( true ) ) )
33+ {
34+ // START CLIENT
35+ BoltLauncher . StartClient ( ) ;
36+ }
3737
38- GUILayout . EndArea ( ) ;
39- }
38+ GUILayout . EndArea ( ) ;
39+ }
4040
41- public override void BoltStartBegin ( )
42- {
43- ShowGui = false ;
44- }
41+ public override void BoltStartBegin ( )
42+ {
43+ ShowGui = false ;
44+ }
4545
46- public override void BoltStartDone ( )
47- {
48- if ( BoltNetwork . IsServer )
49- {
50- string matchName = Guid . NewGuid ( ) . ToString ( ) ;
46+ public override void BoltStartDone ( )
47+ {
48+ if ( BoltNetwork . IsServer )
49+ {
50+ string matchName = Guid . NewGuid ( ) . ToString ( ) ;
5151
5252 BoltMatchmaking . CreateSession (
53- sessionID : matchName ,
53+ sessionID : matchName ,
5454 sceneToLoad : "Tutorial1"
5555 ) ;
56+ }
57+ }
5658
57- // BoltNetwork.SetServerInfo(matchName, null);
58- // BoltNetwork.LoadScene("Tutorial1");
59- }
60- }
59+ public override void SessionListUpdated ( Map < Guid , UdpSession > sessionList )
60+ {
61+ Debug . LogFormat ( "Session list updated: {0} total sessions" , sessionList . Count ) ;
6162
62- public override void SessionListUpdated ( Map < Guid , UdpSession > sessionList )
63- {
64- Debug . LogFormat ( "Session list updated: {0} total sessions" , sessionList . Count ) ;
63+ foreach ( var session in sessionList )
64+ {
65+ UdpSession photonSession = session . Value as UdpSession ;
6566
66- foreach ( var session in sessionList )
67- {
68- UdpSession photonSession = session . Value as UdpSession ;
69-
70- if ( photonSession . Source == UdpSessionSource . Photon )
71- {
72- BoltNetwork . Connect ( photonSession ) ;
73- }
74- }
75- }
76- }
67+ if ( photonSession . Source == UdpSessionSource . Photon )
68+ {
69+ BoltNetwork . Connect ( photonSession ) ;
70+ }
71+ }
72+ }
73+ }
7774}
0 commit comments