Base connection to Master
- Create a new scene
- Create an empty object in the scene and name it, for example --MASTERSERVER*.
- Select this object and click Add Component and then MasterServerBehaviour.
- Create a second empty object and name it, for example --MASTER_CONNECTOR*.
- Select this object and click Add Component and then ClientToMasterConnector.
If you now start game in editor you can see console log output:
*You can choose any name that suits you. I name important objects in the scene starting with two dashes. This gives me an understanding of what object is doing important work.
The master server starts automatically only in editor mode. The Auto Start In Editor checkbox helps you enable or disable automatic start of the Master server in the editor. To automatically start the Master server after the build, use the command-line argument - msfStartMaster or run it programmatically.
How does it all work?
- MasterServerBehavior starts and checks if it has any modules. If the modules are found, the master server starts each module and connects all the necessary dependencies.
- ClientToMasterConnector also starts automatically if the ConnectOnStart checkbox is on, otherwise you will have to start the connection either manually or using the command-line argument -mstStartClientConnection.
Can I have the server and client in different scenes?
Of course! Just place an object with the MasterServerBehaviour component in one scene, and an object with the ClientToMasterConnector component in another scene. You can even use them in different projects.
There's really no "best" setup when working with the framework - you do what suits you best.