Search Unity

Steam can't be initialized

Discussion in 'Scripting' started by MikeyJY, Jan 11, 2021.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I get this error in console:
    Code (CSharp):
    1. [Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.
    2. UnityEngine.Debug:LogError(Object, Object)
    3. SteamManager:Awake() (at Assets/Scripts/Steamworks.NET/SteamManager.cs:101)
    But a simple steamworks method like SteamFriends.GetPersonaName() works and return correctly and in the steam app, it says "Playing My game name" for me, so steam is actually initialized, but this returns false: SteamAPI_Init()
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Do you have a "steam_appid.txt" file (containing your app's Steam ID) in your active directory? (Reminder: this file should only be used for testing, and should not be included when you actually upload your game to Steam.)

    And have you modified the Steamworks.NET code to use the same app ID?
     
    Rachan and MikeyJY like this.
  3. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I think dll files were broken. I downloaded steam_api.dll and steam_api64.dll from https://www.dll-files.com/steam_api.dll.html and https://www.dll-files.com/steam_api64.dll.html and it worked.

    I have one more question. steam_appid.txt is in the project folder(D:/Unity/Projects/Project Name/steam_appid.txt). When I build the game I delete it from there and place it in the folder where executable is, is that correct? Also steam_api.dll and steam_api64.dll are in the Assets/Plugins/x86/steam_api.dll and Assets/Plugins/x86_64/steam_api64.dll, but a lot of games made in unity have these 2 dlls also in the folder where executable is located. Also, many steam games made with unity have another file: GameName_data/Plugins/CSteamworks.dll. I don't have that file anywhere. What is that for?
     
    Rachan likes this.
  4. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    There's no reason to delete steam_appid.txt from your project folder. You should not copy it into your build folder unless you are trying to run your build outside of Steam. You should particularly make sure not to include it when you actually upload your game to Steam, to be distributed through their system.

    My understanding is that it's essentially just a way to tell Steamworks.NET that it should ignore the part of the code that normally says "if someone is trying to run me without going through Steam, shut down and launch through Steam instead".

    I did not do anything special with the dll files in my Steam games and did not have any trouble with them. I don't appear to have a CSteamworks.dll anywhere.

    You might have better luck asking about this stuff on the Steamworks Development Group, since your questions are more related to Steam than to Unity.
     
    Rachan likes this.
  5. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    Sometimes you can trick the game to think it is purchased on steam even if it is just a crack and you can play multiplayer with cracks by placing some dlls. When I was a kid I cracked games, now I wish that my game isn't going to be pirated
     
  6. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Oh, games can certainly be cracked. I don't follow this closely, but my understanding is that for popular games (with a lot of people who want to crack it), the best available DRM protection only buys you days; perhaps a week or two. After that it gets cracked anyway. Protecting software while still allowing it to run on the bad guy's own computer is really hard; it's like trying to make a safe that will keep your valuables safe even though the safe is located inside the thief's home and has a window that lets him look inside.

    (Of course, obscure games can go much longer without being cracked; but that's mostly because no one is seriously trying.)

    The only protection that really holds up is if the game actually takes place on a server that the publisher controls and can't be played offline at all. (And even then, someone might try to hack your server.)

    IIRC Steam does have their own copy-protection suite that they encourage developers to apply to their games, but it only works if your game is written in C++, and therefore isn't really an option for Unity games. Steamworks.NET just has the aforementioned check where it tries to shut down and launch itself through Steam if it isn't already, and that check specifically has an easy back door where you just put a steam_appid.txt file in your working directory. It's barely a step above asking politely.

    If you want more than that, I can't point you towards any specific resources. You'll just have to do some research I suppose.
     
    MikeyJY likes this.