rlabrecque / Steamworks.NET

Steamworks wrapper for Unity / C#
http://steamworks.github.io
MIT License
2.72k stars 362 forks source link

[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information. #83

Open Kew opened 8 years ago

Kew commented 8 years ago

Hi, I'm running Unity 5,3,1f Personal.

My first game was recently Greenlit http://steamcommunity.com/sharedfiles/filedetails/?id=542685634 so this is my first time getting a game onto Steam.

I imported the SteamWorks.NET Unity component as per the instructions here https://steamworks.github.io/installation/

steam_api.dll did not appear in the root, but the steam_appid.txt did and I edited it, making it my own appid. While poking around I found steam_api.dll under Assets/Plugins/x86.

So not 100% sure that the import went correctly.

When I have steam running and launch the game in Unity UI I get this error. Same if I run a stand alone build.

[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information. UnityEngine.Debug:LogError(Object, Object) SteamManager:Awake() (at Assets/Scripts/Steamwork.NET/SteamManager.cs:97)

Is this normal? Is it because I am not launching it from Steam?

gamenew09 commented 8 years ago

Copy the steam_api.dll into the executable folder. That should work.

Kew commented 8 years ago

Manged to solve it by taking a leap of faith and uploading a depot to SteamWorks and it worked!

Didn't have to copy steam_api.dll into the root. When I build the binary it ends up there anyway.

So it looks like that error is what happens when you don't launch it from Steam?

Kew commented 8 years ago

On another machine, The first time I launched the game from Steam I got the error.

[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information. UnityEngine.Debug:LogError(Object, Object) SteamManager:Awake() (at Assets/Scripts/Steamwork.NET/SteamManager.cs:97)

Subsequent times, all good.

thestonefox commented 8 years ago

I'm having this same issue in the Unity editor. How can you launch your game within the Unity editor and get support for Steamworks?

Doesn't seem valid that you have to do a build to test the Steamworks functionality.

Also, when I did the import of the Steamworks.Net unitypackage it didn't copy the dll's to the root directory (which I believe is now the correct process?)

I have my steam_appid.txt file in my root directory and I updated the number.

I've run DbgView and I don't see any output from Steam that would shed any light on what the issue may be.

Unity 5.3.4f1 64 bit

thestonefox commented 8 years ago

I've resolved the issue, I'll post in case someone else hits the same problem.

The issue is because my app ID is for an unpublished app and my steamworks account is not the same as the account I log into steam on my desktop with, it means the API doesn't have permission to access the App ID.

I resolved it by adding a permission for my desktop steam account within my steamworks web page and now it's working.

This is probably obvious to most people! :) but if you're stumped like I was, then try this! :)

Astiolo commented 8 years ago

I'm having a similar problem. When I run my game within Unity, DbgView reports that it's "unable to locate a running instance of Steam, or a local steamclient64.dll". But with a build (without a local steam_appid.txt) it works fine.

I've got the steam_api64.dll in the root directory and I've tried it with and without the appid file, but it's the same result.

What I find strange is that when I put the appid file in the build directory it creates the same problem when I thought you had to put it there to solve it. I have triple checked that it's got the correct id in it.

Astiolo commented 8 years ago

Looks like I just had to run Unity as administrator

sonnyg007 commented 8 years ago

@thestonefox Thanks for taking the time to post your fix. Was stuck for a few hours trying to figure what was the problem. Making sure the user logged into steam had permissions for the AppID did the trick.

Tagette commented 8 years ago

@Astiolo Did you ever find a better solution then running Unity as administrator? Seems bad to force a customer to launch the game as administrator every time they play the game. It is also quite annoying as a developer. I have the same issue on my Windows 8 machine using Unity 5.4.0f3. All my other computers don't have this issue.

Edit: It might be worth noting that all my windows accounts are administrator accounts.

Astiolo commented 8 years ago

@Tagette, The game shouldn't need to be run as admin, just Unity when you're running the game from within the engine. Really you shouldn't need to even do that but it solved the problem for me.

rlabrecque commented 8 years ago

How does your steam launch? Games should be running at the same process elevation as Steam, If Steam is being run as Admin then the Unity Editor will need to be as well.

When you run stuff from Steam it will inherit the same elevation level as Steam itself so it will always work.

Tagette commented 8 years ago

@rlabrecque We have not been launching through steam but I imagine it would have the same issue because we don't have steam run as administrator. We run from the .exe and have the steam_appid.txt present.

@Astiolo It seems we have different issues then. I'm using the same Steamworks .Net in Unity 5.1 and I don't have this issue running it on my windows 8 computer. However a different build running 5.4 fails to load the dll unless it is ran as administrator.

Magris commented 8 years ago

@rlabrecque I have same issue other appid(480 or published) is working but not mine T.T(492610) What can i do??

Unity 5.3.6 OSX 10.11

gycot commented 8 years ago

Giving my alt account permissions solved the biggest problem I had, thanks!

One thing of note - I had to manually copy steam_appid.txt to my build directory, and only then would it start up. Did anyone else have to do the same, or should Build be creating/copying the file to the root of the build dir?

marnel-estrada commented 7 years ago

Hello. I have the same issue. How do you give "account permissions"? Is it to be setup in Steamworks or in Steam?

rlabrecque commented 7 years ago

This is done via one of two ways.

A: Your account must be in your Steamworks partner group. B: Your account owns the game through a "Developer Comp" (red) CD-Key.

Essentially it just means that your game should show up as playable in your Steam library.

@gycot: Yes, you need to manually copy steam_appid.txt if you need it. You're not supposed to ship it to customers as Steam injects the appid itself when it's run from Steam. You can ensure that you're running from Steam by calling SteamAPI.RestartAppIfNecessary with your AppId (as is done in SteamManager)

Nakano37 commented 7 years ago

I've tried everything in this thread and I'm still getting the same SteamAPI_Init() failed error... strangely it works if I replace my appID with 480 in the steam_appid.txt file (comes up as Spacewar, of course). Since that's the case it makes me fairly sure it something wrong with how I've got the app setup, but the user I'm logged in with on steam is an admin on the application with full permissions for everything... Does anyone have any other idea on what I might be missing?

Wuzseen commented 7 years ago

I am also experiencing this same issue. I've added my relevant steam accounts on steamworks in the "Everyone" group which should give them permissions on the app right?

mikeshultz commented 7 years ago

Having the same/similar problem. At this point I'm not entirely sure where the problem lies(Steamworks.Net, Steamworks SDK). Trying to get a Linux x86_64 build running for a headless server. Game is packaged as a dedicated server and deployed using steamcmd. Potentially relevant info from the logs:

[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
[S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.so.
[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.

I can only guess it might have to do with not having a steam client running(I can't for a headless system) but steamcmd should have my credentials. Are there any logs anywhere on Valve's side that can be checked to see if there were permissions issues?

Most of the suggested fixes here or elsewhere just don't work, including the official suggestion of symlinking steamclient.so to .steam/sdk32.

The game is packaged with steampipe(ass a tool as described here on their partner site, which purposely includes steamclient.so and steam_appid.txt as redistributables. But an strace only suggests that it's looking for a pid file isntead of steamclient.so but I'm no expert at reading these traces.

Not really sure where to go from here, but would love some ideas.

mikeshultz commented 7 years ago

Looks to be the same problem with both SteamAPI.Init() and GameServer.Init(). On Linux, anyway.

Nakano37 commented 7 years ago

we had to get help from valve to solve it... something was misconfigured on their end.

mikeshultz commented 7 years ago

@Nakano37 Could I ask what avenue you used to get support for that? They have pages on their site that specifically state that no support is offered for Steamworks SDK.

Wuzseen commented 7 years ago

Same issue here. Posting on the steamworks dev forum had someone at valve fix it. Our default app configurations were missing

Get Outlook for iOS

On Wed, Nov 16, 2016 at 8:58 PM -0500, "Mike Shultz" notifications@github.com wrote:

@Nakano37 Could I ask what avenue you used to get support for that? They have pages on their site that specifically state that no support is offered for Steamworks SDK.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Nakano37 commented 7 years ago

Posted on their developer group discussion forum, and after going back and forth with various people, eventually a valve employee answered and was able to look into it.

mikeshultz commented 7 years ago

I was entirely mistaken. On Linux, GameServer.Init() worked! When I wrote that post, my conditional was failing between using that and SteamAPI.Init(). So something to keep in mind for anyone trying to get a headless linux server running, I guess.

Now I just have to figure out which calls go with which.

Phonebox commented 7 years ago

just to note here I was struggling with the same issue. The solution is to restart steam a few times. If it shows up in steam you should be able to play it. Also, I have to note here: I had no problem with a generated test key.

benmcnelly commented 7 years ago

Having the same issue. I added my steam app id to the file steamworks.NET created in the root of the project, restarted Unity and Steam multiple times, and I am sure my user has permissions to the steam app.

rlabrecque commented 7 years ago

Hey benmcnelly, have you tried using DbgView to see if Steam is providing and debug information?

https://github.com/rlabrecque/SteamManager/blob/master/SteamManager.cs#L90

AW111 commented 7 years ago

I'm getting a "SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient64.dll" error when trying to test Steamworks in the Unity editor. This occurs even when I used the default 480 app ID. Where is steamclient64.dll supposed to be located? I can't find a copy, although everything else seems to have been installed.

rlabrecque commented 7 years ago

It depends on what version of Unity you're on. On modern versions it just has to be next to CSteamworks.dll in the Plugins/x86_64/ folder, on older (<5.2 or so, give or take a version) it needs to be in the project root, NEXT TO 'Assets/', 'ProjectSettings', etc.

What version of Unity are you on? The RedistInstall script should have copied it over for you automatically if it needed to.

AW111 commented 7 years ago

Thank you for your reply. A search of the Unity project doesn't find steamclient64.dll anywhere in the hierarchy, though (there are two folders with a similar name, but the file itself isn't there). Does it have to be downloaded separately?

rlabrecque commented 7 years ago

Oh sorry, I kind of misread that!

The local steamclient.dll is only for dedicated servers. In most cases it's just trying to find a running steam client and failing. Valve's new documentation on SteamAPI_Init has better reasons for this. Does your game show up in your Steam library for example?

AW111 commented 7 years ago

Yes, it shows up in my Steam library. (and it offers to "download" it although there's no build on Steam - I was just running it in Unity's editor). It says I just "played" it today, so it's evidently able to monitor my usage of it. So what would be the cause of the error I was getting?

AW111 commented 7 years ago

It seems to be working now, for whatever reason.

Suvitruf commented 7 years ago

Same problem. In editor it works fine. But in standalone win build I get this error: [Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.

Tsury commented 6 years ago

@Suvitruf Did you end up solving this?

NJBischoff commented 4 years ago

If anybody else gets this error, you need to be logged into a Steam Account that has permission to play the game (if it is unreleased). Login to your Steam Client with the granted key (you can access the Beta branch and the app id etc). Then load Unity and it will connect.

PAYALzariya commented 4 years ago

hi I am trying to login in steam using 480 appid, but issues are when I am login in unity editor, it work fine. when I make exe build and run it showing error like below :

[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.

What I can do?

Please give me a suggestion, I need help to solve this issue.

Thanks, advance.

NJBischoff commented 4 years ago

hi I am trying to login in steam using 480 appid, but issues are when I am login in unity editor, it work fine. when I make exe build and run it showing error like below :

[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.

What I can do?

Please give me a suggestion, I need help to solve this issue.

Thanks, advance.

Both the steam_api.dll and the steam_appid.txt need to be in the same folder as the executable. Other posts here mention steamapp_id.txt - It's steam_appid.txt and needs to contain 480. https://www.reddit.com/r/Unity3D/comments/9xm16d/steamworksnet_steamapi_init_fails_on_steam_not_in/

PAYALzariya commented 4 years ago

Hey Buddy, thanks for quick response, I had tried your solution but it didn't work for me I put steam_appid.txt file into steam_api_dll. sending you error screenshot,

let me know if you have a solution Untitled2

janiguid commented 2 years ago

Hi there so I'm running into an issue. When I make a development build, and open it from steam, my game works fine. When I make a release build, it suddenly stops working. The game still opens but the achievements are no longer popping up.

Additionally, when my friends try to make a dev build on their computers, it simply wouldn't show up.

Anyone run into a similar issue?

IdleLemonz commented 2 years ago

Hi there so I'm running into an issue. When I make a development build, and open it from steam, my game works fine. When I make a release build, it suddenly stops working. The game still opens but the achievements are no longer popping up.

Additionally, when my friends try to make a dev build on their computers, it simply wouldn't show up.

Anyone run into a similar issue?

I am having very similar issues. Running the game in the editor is fine, no errors. If I go "Build", I get errors. If I go "Build and Run", I do not get errors, and the game works. However, if I close the game, navigate to the .exe, then open it through Windows File Explorer, it crashes. Weird.

Development build or non-development build made no difference but definitely weird stuff going on.

Furthermore, when running inside Unity, I was able to get Steam specific information like my Steam ID and display name. In my case, my game is already released, and I am trying to set up cloud saves. It correctly grabbed my steam ID and made a new subfolder for that unique Steam user for the save data, while running in Unity. But as I said, builds crashed.

The error was simply: "[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information."

I got the unity package from releases here: https://github.com/rlabrecque/Steamworks.NET/releases

The instructions here: https://steamworks.github.io/installation/ are what I used. It says nothing about any .dll files, so when I saw people talking about that, I was confused. I simply imported the unity package. When I look at the build, the only .dll files are UnityPlayer.dll and WinPixEventRuntime.dll.

I searched for the steam_api.dll file, it was in the plugins folder of the steam project, and manually added it next to the .exe file. It stopped some of the crashing in the game, ie, my menus loaded correctly, but the development build still produced the same error even with the .dll present: "[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information."

I find it incredibly strange that Build & Run works but Build doesn't.

Because my game is released, it is in my library so I obviously have permissions. I am using Unity 2019.1.13f1 and have been afraid to upgrade as you know how Unity loves to break when you upgrade versions, so reluctant to do that unless it's a definite fix.

I am signed in to Steam and online currently also. I believe I used the correct appID in the txt file, but just to clarify, if you're in Steamworks, your appID is the numbers in the address of your landing page? ie, https://partner.steamgames.com/apps/landing/1400560

Considering the missing .dll, I am wondering if part of the issue is the unitypackage either not importing correctly, or some script is not handling the necessary .dll files correctly? To me that sounds the most likely reason for the errors, from what I can tell, but that single .dll file did not fix it, are there others I need? I am feeling it may not be something I did wrong.

I did also update the appID in the txt file assuming I have the correct app ID, which I think I do.

UPDATE I disabled the "Steam Manager" script, removed all Steamworks API related code from my game, and my game doesn't crash anymore, but development builds still throw the error. To me that confirms that it is not my error in any way. And it can't be related to the Steam Manager script since it's disabled now, so it must be something else that happens from the Steamworks.NET API, probably at build time.

In the off-chance that it's Unity version related, I'm going to try some different LTS versions of Unity and the latest version, just in case, with a backup of my project in GIT. Will update you of failure / success.

UPDATE 2 Upgrading from 2019.1.13f1 to 2019.4.32f1 LTS did not work. Upgrading from 2019 LTS to 2020.3.2f1 LTS did not work. Upgrading from 2020 LTS to 2021.2.0f1 ....

I'm out of options, can't think of anything else to try. At least upgrading to 2020 didn't break the game, but 2021 stuffed up the main monitor to display the game. It didn't fix the Steamworks.NET error message either. I can't use SteamManager without crashing the game.

IdleLemonz commented 2 years ago

I may have found a solution, for my case at least. Someone here said they fixed it by putting the steam_appid.txt file in the build folder. That fixed it. If the .txt file is supposed to be included in the build folder, it wasn't. When I run the build now, I do not get errors.

immurecreations commented 2 years ago

My game is for sale on steam I have entered the correct AppID I have restarted steam numerous times I have restarted unity numerous times but still, it comes up with the error mentioned in the title of this issue any help? I am just trying to use it in the unity editor, ive tried it in a build of the game too and it worked on neither I havent uploaded it to steam and don't think I will unless I get it to work here

I would like to add that it worked perfectly with the AppID for Spacewar, but not my game

rlabrecque commented 2 years ago

Hey there @immurecreations, if it worked with 480 but not your appid, the two things that I'd check first are: 1. Are you logged in to Steam with an account which owns a license for your AppId? 2. Did you save the file as ASCII/UTF8-no-BOM?

immurecreations commented 2 years ago

How do I check the second option? I’m sure number 1 should be valid since my account was given the game throughout the publishing process

immurecreations commented 2 years ago

@rlabrecque i checked the encoding in notepad++ and its UTF8 is this correct?

immurecreations commented 2 years ago

it works now! :)

valsan commented 1 year ago

I may have found a solution, for my case at least. Someone here said they fixed it by putting the steam_appid.txt file in the build folder. That fixed it. If the .txt file is supposed to be included in the build folder, it wasn't. When I run the build now, I do not get errors.

This one worked for me too. I'm not sure if having the appId in the root folder is bad practice though.

IdleLemonz commented 1 year ago

Just to be clear, best practice is that you include the steam_appid.txt in the root folder while testing only. When you build for Steam, you should not include that .txt file.