When starting up a game using Epic Online Services, your game logic needs to select the correct environment to use. Epic generally provides 3 environments: Development, Staging, and Live. Each have their own Sandbox IDs and Deployment IDs. Generally speaking, you should include configuration data for all 3 environments in your build, and based on launch arguments from the Epic Launcher, decide which environment to actually use. In all cases, when running your game in a local development environment and not from the Epic Launcher, it will use the default configured environment.
For Unity, Epic recommends the PlayEveryware EOS plugin. Epic has actually taken over development of the plugin. You can follow the official instructions to enter your environment configuration values into the project. As long as you enter all 3 environments, when the game is run, the plugin will check the Sandbox ID that was passed in via the Epic Launcher and match it to one of your existing environments, then use that for the game.
For Unreal Engine 5.1 and newer, Epic recommends using their EOS Online Services plugin. However, the configuration here does not seem to allow multiple environments for the same platform. You can only configure one environment per platform, and must make a different build for each environment.
However, the older EOS Online Subsystem in Unreal Engine 5 does allow for multiple environments to be configured. It will then select the correct one based on the Sandbox ID from the Epic Launcher command line, as the Unity plugin does. In your Engine config, set up the 3 environments:
[/Script/OnlineSubsystemEOS.EOSSettings]
DefaultArtifactName=<live artifact name>
+Artifacts=(
ArtifactName="<dev artifact name>",
ClientId="<client ID>",
ClientSecret="<client secret>",
ProductId="<product ID>",
SandboxId="<dev sandbox ID>",
DeploymentId="<dev deployment ID>",
EncryptionKey="<encryption key>"
)
+Artifacts=(
ArtifactName="<stage artifact name>",
ClientId="<client ID>",
ClientSecret="<client secret>",
ProductId="<product ID>",
SandboxId="<stage sandbox ID>",
DeploymentId="<stage deployment ID>",
EncryptionKey="<encryption key>"
)
+Artifacts=(
ArtifactName="<live artifact name>",
ClientId="<client ID>",
ClientSecret="<client secret>",
ProductId="<product ID>",
SandboxId="<live sandbox ID>",
DeploymentId="<live deployment ID>",
EncryptionKey="<encryption key>"
)
Note that when running your game locally, you can add the "EOSArtifactNameOverride" command line argument to forcibly select the environment you want to use, regardless of the defaults set in the config file. This will not work in the live game running from the Epic Launcher, though. Example: <path to game>/<game>.exe -EOSArtifactNameOverride=<dev artifact name> -EpicPortal
(Also note that for Unreal projects, adding the "EpicPortal" command line argument signals Unreal that it can initialize the eCommerce system if you need to test that locally.)
In Unreal 4.27, the Online Subsystem logic does not select based on Sandbox ID. It will try to select based on the Epic Launcher "EpicApp" argument. However, that argument is the Artifact ID of the game. That ID does not change between environments. You would have to set up different Artifacts in the Epic Dev Portal for development, staging, and live in order to use this feature. Without modifying code, you will again need to make different builds for each environment. In this case, you can change the "DefaultArtifactName" config setting to match the particular environment you are targeting.
If you want to modify Unreal 4.27 source to detect the environment via the command line, check Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOS/Private/EOSSettings.cpp. Compare it to the same file in the source for Unreal Engine 5 and copy over the logic for selecting the artifact settings based on the Sandbox ID.
As a side note, whenever your game is run the from the Epic Launcher, it has multiple command line arguments. You can view these arguments in Windows via several different methods. We recommend Process Explorer. A typical command line will look like this:
<path to game>/<game>.exe -AUTH_LOGIN=unused -AUTH_PASSWORD=<password> -AUTH_TYPE=exchangecode -epicapp=<artifact ID> -epicenv=<Dev/Stage/Prod> -EpicPortal -epicusername="<username>" -epicuserid=<user id> -epiclocale=<locale> -epicsandboxid=<sandbox ID>