Home > Enterprise >  How would I manage 2 different builds for 2 different stores, which requires a little bit of a code
How would I manage 2 different builds for 2 different stores, which requires a little bit of a code

Time:01-06

Let's say I want to publish my game on both Steam and Epic Games. Both have an SDK with certain services like matchmaking.

I don't want to make 2 projects and basically maintain both of them just to be able to achieve this. How do I activate/deactivate certain code depending on which version I'm building (the Steam one, or the Epic Games one). I read about #if directives, but those seem to work only when checking build target platform (Android, etc).

  • Can I make use of these directives to achieve my goal?
  • Can I include both sdks and check via code if it's the Steam or the Epic version and initialize the correct one accordingly some way?.

CodePudding user response:

You can add and define your own preprocessor directives #if STEAM or #if EPIC.

#if STEAM
  //do something with STEAM API
#elif EPIC
  //do something with EPIC API
#endif

To do this you need to open "Project Settings->Player->Script Compilation->Scirpting Define Symbols" and there you can find a list of all custom preprocessor directives that Unity will use to compile your project.

If you wish to do the same during build process automatically you can set PlayerSettings.SetScriptingDefineSymbolsForGroup

PlayerSettings.SetScriptingDefineSymbolsForGroup
(BuildTargetGroup.Standalone, "STEAM");

Fore more information see this PlatformDependentCompilation

You can do the same thing for all plugins and DLL you want to include in your project via Define Constraints

  •  Tags:  
  • Related