Changing sandboxid for epic games launcher? #234
Replies: 2 comments 1 reply
-
To anyone stuck on this issue, I came up with a sneaky workaround, since this plugin's native libraries run before we can do anything on the Unity side, I just created a simple launcher program that will do the necessary changes to the EpicOnlineServicesConfig file before actually launching the game. When uploading to dev sandbox you just need to configure it to (AppLaunch) to run the launcher instead of your game. using System.Diagnostics;
using System.Net.Mime;
using Newtonsoft.Json;
const string ExeName = "<yourgame.exe>";
//
// The ids of the sandboxes and deployments
//
var sandboxDeployments = new Dictionary<string, string>()
{
{"<dev sandboxid>", "<dev deploymentid>"},
{"<stage sandboxid>", "<stage deploymentid>"},
{"<live sandboxid>", "<live deploymentid>"}
};
var mainArgs = Environment.GetCommandLineArgs(); //all the EGL arguments to relay to the game
var currDir = Environment.CurrentDirectory; //the install directory of the game
var sandboxId = Environment.GetCommandLineArgs().FirstOrDefault(c => c.Contains("epicsandboxid"));
//
// Does it have EGL argument
//
if (string.IsNullOrEmpty(sandboxId) == false)
{
//
// Get the EpicOnlineServicesConfig json file
//
var dataFolder = Directory.GetDirectories(currDir).FirstOrDefault(d => d.EndsWith("_Data"));
if (string.IsNullOrEmpty(dataFolder))
return;
var configFilePath = Path.Combine(dataFolder, "StreamingAssets", "EOS", "EpicOnlineServicesConfig.json");
sandboxId = sandboxId.Replace("-epicsandboxid=", string.Empty);
//
// Read the file to replace the sandbox and deployment values
//
var config = JsonConvert.DeserializeObject<EOSConfig>(File.ReadAllText(configFilePath));
config.sandboxID = sandboxId;
config.deploymentID = sandboxDeployments[sandboxId];
File.WriteAllText(configFilePath, JsonConvert.SerializeObject(config));
}
//
// Launch the game with the arguments passed by the launcher
//
var game = Process.Start(new ProcessStartInfo(ExeName, string.Join(' ', mainArgs)));
//
// Wait for the game to complete, it might not be required, but I assumed here that
// epic launcher tracks the launched process id to track time in game
//
game.WaitForExit();
//
// The config class of the json file
//
class EOSConfig
{
public string productName;
/// <value>Version of Product</value>
public string productVersion;
/// <value><c>Product Id</c> defined in the [Development Portal](https://dev.epicgames.com/portal/)</value>
public string productID;
/// <value><c>Sandbox Id</c> defined in the [Development Portal](https://dev.epicgames.com/portal/)</value>
public string sandboxID;
/// <value><c>Deployment Id</c> defined in the [Development Portal](https://dev.epicgames.com/portal/)</value>
public string deploymentID;
/// <value><c>Client Secret</c> defined in the [Development Portal](https://dev.epicgames.com/portal/)</value>
public string clientSecret;
/// <value><c>Client Id</c> defined in the [Development Portal](https://dev.epicgames.com/portal/)</value>
public string clientID;
/// <value><c>Encryption Key</c> used by default to decode files previously encoded and stored in EOS</value>
public string encryptionKey;
/// <value><c>Flags</c> used to initilize the EOS platform.</value>
public List<string> platformOptionsFlags;
/// <value><c>Flags</c> used to set user auth when logging in.</value>
public List<string> authScopeOptionsFlags;
/// <value><c>Tick Budget</c> used to define the maximum amount of execution time the EOS SDK can use each frame.</value>
public uint tickBudgetInMilliseconds;
/// <value><c>Network Work Affinity</c> specifies thread affinity for network management that is not IO.</value>
public string ThreadAffinity_networkWork;
/// <value><c>Storage IO Affinity</c> specifies affinity for threads that will interact with a storage device.</value>
public string ThreadAffinity_storageIO;
/// <value><c>Web Socket IO Affinity</c> specifies affinity for threads that generate web socket IO.</value>
public string ThreadAffinity_webSocketIO;
/// <value><c>P2P IO Affinity</c> specifies affinity for any thread that will generate IO related to P2P traffic and management.</value>
public string ThreadAffinity_P2PIO;
/// <value><c>HTTP Request IO Affinity</c> specifies affinity for any thread that will generate http request IO.</value>
public string ThreadAffinity_HTTPRequestIO;
/// <value><c>RTC IO Affinity</c> specifies affinity for any thread that will generate IO related to RTC traffic and management.</value>
public string ThreadAffinity_RTCIO;
/// <value><c>Always Send Input to Overlay </c>If true, the plugin will always send input to the overlay from the C# side to native, and handle showing the overlay. This doesn't always mean input makes it to the EOS SDK</value>
public bool alwaysSendInputToOverlay;
/// <value><c>Initial Button Delay</c> Stored as a string so it can be 'empty'</value>
public string initialButtonDelayForOverlay;
/// <value><c>Repeat button delay for overlay</c> Stored as a string so it can be 'empty' </value>
public string repeatButtonDelayForOverlay;
/// <value><c>HACK: send force send input without delay</c>If true, the native plugin will always send input received directly to the SDK. If set to false, the plugin will attempt to delay the input to mitigate CPU spikes caused by spamming the SDK </value>
public bool hackForceSendInputDirectlyToSDK;
} |
Beta Was this translation helpful? Give feedback.
-
Hi @DVDPT, sorry for such a late reply - I'm going through all our discussions to resolve them. I'm glad this solution worked out for you - did you end up writing that blog post you mention? I'd love to read it. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Is there any built-in way of changing the sandboxid for the one passed via argument by the Epic Games Launcher?
I tried to change the json file before the EOSManager.Init without any success, since the native code runs before Unity.
Am I missing something?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions