Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Build for Steam, GOG and Epic Games

Discussion in 'General Discussion' started by fiwon123, Aug 17, 2023.

  1. fiwon123

    fiwon123

    Joined:
    Jul 11, 2018
    Posts:
    116
    Hello,

    I already have experience with Steam platform but I'm confused with GOG and Epic Games. I thinks these platforms follows the same step-by-step as download the SDK, configure the product on the platform site and implement everything using C# on unity.

    But the doubt is, Do we need to make three build now as we have three platforms? if not, whats the best way to do that as we already have the steam on the project and maybe we need to download more the GOG and the Epic (EOS) too...

    I've read that the GOG for example that exists Steam wrapper too: https://docs.gog.com/steam-sdk-wrapper/?h=steam

    That means that can I download all the SDK and for example, its possible to make something like if Platform.GOG / Platform.Steam / Platform.Epic make something?

    Kind Regards,
    Felipe Inoue
     
  2. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,293
    It mostly depends on which platform-specific features you are using.

    In principle, you want to wrap all specific code in #if statements, like so:

    Code (CSharp):
    1. #if STEAM
    2. SteamManager.SomeThing();
    3. #elif GOG
    4. GalaxyManager.SomeThing();
    5. #elif EPIC
    6. EpicManager.SomeThing();
    7. #endif
    Note that you may have to include using statements that reference these, and think about UI stuff, possibly. Also keep in mind that they may work differently. For example, Steam and GOG both support leaderboards and achievements, but for GOG you need to fetch some data first before you can add an achievement, and they have different handling with regards to async operations.
     
    Ryiah likes this.
  3. fiwon123

    fiwon123

    Joined:
    Jul 11, 2018
    Posts:
    116
    Hello, @Tom163,

    Thanks. I already implemented for GOG and EPIC. I don't know if it was the best implementation but it worked.
    I used the #if statement as you said, but for GOG and EPIC each one needs to handle the login for each user and only after that you can unlock the achievements for example and make other API calls.

    Kind Regards,
    Felipe Inoue
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,937
    Alternatively if you want to better isolate the code for purposes of debugging or if the code that will be handling the platform needs more than just minor differences:
    Code (csharp):
    1. public class PlatformManager
    2. {
    3.     public abstract void SomeThing();
    4. }
    Code (csharp):
    1. public class SteamManager : PlatformManager
    2. {
    3.     public override void SomeThing()
    4.     {
    5.         // code
    6.     }
    7. }
    Code (csharp):
    1. public static class PlatformManagerFactory
    2. {
    3.     public static PlatformManager CreateInstance()
    4.     {
    5.         #if STEAM
    6.         return new SteamManager();
    7.         #endif
    8.     }
    9. }
     
  5. fiwon123

    fiwon123

    Joined:
    Jul 11, 2018
    Posts:
    116
    Hello, @Ryiah,

    Yeah. I think this is the best way for each platform handling your own API Calls.
    Maybe create some interfaces for each important feature like Achievements, Save system...

    Kind Regards,
    Felipe Inoue
     
  6. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,293
    I totally agree that this is a much better approach. Common interface then hide the platform-specific stuff behind it.
     
    Ryiah and MadeFromPolygons like this.
  7. ketchupAfterDark

    ketchupAfterDark

    Joined:
    Oct 19, 2022
    Posts:
    4
    I have a similar issue and not really sure what would be the best approach.
    Only releasing on Itch and Steam.

    At the moment I'm trying to setup Steamworks, achievements etc and I have not worked with it before.
    I'm thinking about doing different versions for the 2 platforms, so they would also have an unique save folder.
    Mainly to make sure, that a possible progress a person made with the itch version would not affect the Steam version and trigger achievements there.

    But maybe I'm just missing something more or less obvious and I'm not real sure what is the common approach for that.

    (I came across this possible situation when starting a game on Epic which I had played on Steam before and my save was there. No achievements at Epic for it, not sure what would have happened vice versa..)
     
  8. fiwon123

    fiwon123

    Joined:
    Jul 11, 2018
    Posts:
    116
    Hi, @ketchupAfterDark,

    The save folder is related with your player settings > Company Name and Product Name.
    The folder will be on appdata/LocalLow/Company Name/Product Name. You will not resolve your problem If you create another project for the other platforms.

    I don't know what you can make to resolve this problem as I didn't care in my game.
    Maybe you can add in your save_name the platform too. For example in Steam you can write Save_Game_Steam and on Epic Save_Game_Epic.

    Kind Regards,
    Felipe Inoue
     
  9. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,293
    Update on this:

    My current approach, which appears to be working, is to have a dedicated loading scene that is platform specific. So I have one Init_Steam scene, one Init_GOG scene, etc.

    My build automation (I'm using SuperUnityBuild) supports having different scene lists per release type.

    The init scenes set up whatever Steam/GOG/Epic/whatever specific stuff they need to handle, and define a pre-processor directive, so that I can do #if STEAM #elif GOG etc. code blocks for when I call achievements, leaderboards, etc.
     
    marcoantap likes this.
  10. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    748
    Why nobody put this in Asset Store yet? Would be a gold mine.
     
  11. fiwon123

    fiwon123

    Joined:
    Jul 11, 2018
    Posts:
    116
    @Gekigengar, I don't know
    Maybe is very difficulty to maintain or people just pay someone to make the other platforms...
     
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,937
    Supporting an asset is expensive and can quickly turn a gold mine into a gold sink.
     
    Peter77 likes this.
  13. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,650
    As a former Asset Store publisher, some customers also act as if they own your life because they have spent $10 on your asset. When something doesn't meet their expectations, some can be quite rude. It's not worth the money.
     
    neginfinity, Ryiah and spiney199 like this.