- Home /
How to get Steam Username?
I know very few Unity games have actually made it to Steam, but I'm planning for mine to be one of the few. However, I've come across a problem. (I've gotten no help from Unity Forums)
How do I retrieve the Steam username of the player and put it into a string variable? Is this value stored somewhere on your computer? Or can it be retrieved from a Steam website location?
Answer by chrisjjones · Aug 03, 2012 at 07:32 PM
You could possibly use this C# wrapper for the SteamWeb API:
https://github.com/Overv/SteamWebAPI/
If you're looking for the Steam username of the current player, I would imagine you would need to hook into the SteamWorks SDK in some way. I'm not sure if there is a C# wrapper for that but I do know that several XNA games have made it to Steam. It might be worth searching around on some of the XNA specific forums as I assume the Unity solution would be similar.
Thanks, but do you know how to apply this to Unity? Do you have to put this in a Unity Project folder or something?
You will need to build the S$$anonymous$$mWebApi library and drop the created DLL into the Plugins folder of your Unity project. Then just add
Using S$$anonymous$$mAPI;
to the top of any class you want to access the library from.
Also, make sure to build the library for .NET 3.5 Client or it won't work in Unity. In order to get it to build I had to change request.Host = "api.s$$anonymous$$mpowered.com:443" to request.Headers.Set(HttpRequestHeader.Host, "api.s$$anonymous$$mpowered.com:443") in their source.
I believe using Plugins requires Unity Pro, so that is another caveat to be aware of...
Sorry, how do you build it? With what program? Thanks by the way!
Your answer
![](https://koobas.hobune.stream/wayback/20220613074741im_/https://answers.unity.com/themes/thub/images/avi.jpg)