ご留意ください:Photon TrueSyncとThunderの開発は停止されており、今後はアップデートもパリリースされません。既存のアプリケーションへの影響はありませんが、現在開発中のアプリケーションについてはマイグレーションを推奨しています。
Configuring Photon Thunder
Configuration File
This file can be found inside your Resources folder, after you download and import the Thunder Package. It contains all major configurations needed to your Thunder project works.
Clicking on the configuration file, and going to the Inspector View you will be able to change the settings right from the editor, without the need of any code.
The main configuration fields are:
- Application ID: here you will need to put your project App ID created from your account with Photon. Just past it and you are ready to go.
- Hosting: this setting configure which type of server you will use.
- Photon Cloud: in this mode, the project will use a Photon server to manage the connection between your players. Using this, you can select a default region among all servers.
- Self hosted: you can use your own Photon server using this option. Just set the IP and Port of the hosted server.
- Target Connection Type: this field configures the connection capabilities of your game instance, that can be:
- Punch + Relay: using this configuration, when a new player connects to your host, the NAT Punchthrough process will be performed to create a direct connection between the client and the host, if this step was not successful, it will fallback to the Relay Only connection.
- Relay Only: connection in which the data exchange is made using the Photon server as a Relay server. This type of connection can be more slow than the direct connection, but has the guarantee to always work.
How to change Thunder Configuration by code ?
The Thunder Configuration asset is a ScriptableObject, where all the settings can be changed at runtime, before enabling the matchmaker. To get access to this instance into your scripts, you can use the snippet below:
C#
using UnityEngine.Networking;
public class RuntimeCfg : MonoBehaviour
{
private PhotonThunderConfig config;
void Start()
{
this.config = PhotonUtils.getThunderConfig();
}
}
From there, you can change the settings using the reference instance:
C#
void Configure() {
// Set your Application ID
this.config.appId = "e0daaa07-3e6e-4637-b47a-369372992d81";
// Use your own self hosted server or the Photon server
this.config.useLocalServer = false; // true to use self hosted server
// IF USING SELF HOSTED SERVER
this.config.localServerIp = "192.168.0.10";
this.config.localServerPort = "7076";
// IF USING PHOTON SERVER
// Use the Punch + Relay connection
this.config.connectionType = PhotonThunderConnectionType.PUNCH_RELAY;
// Set the default region used to manage the connections
// You can change US to any other region on the Enum
this.config.currentRegion = PhotonRegions.Regions.US;
// Use the Relay Only connection
this.config.connectionType = PhotonThunderConnectionType.RELAY;
}
Back to top