0

我在 c# .NET 中编程我没有使用 Unity,我想通过 steamworks 收集玩家的头像并将其放入图片框中。我做了一些事情,但不知道接下来会发生什么。我是 Steamworks 的新手,无法正确使用它。

var avatarInt = SteamFriends.GetMediumFriendAvatar(SteamUser.GetSteamID());
uint Width, Height;
SteamUtils.GetImageSize(avatarInt, out Width, out Height);
var abc_test = (SteamUser.GetSteamID().ToString());
byte[] avatarstream = new byte[4 * (int)Width * (int)Height];
SteamUtils.GetImageRGBA(avatarInt, avatarstream, 4 * (int)Width * (int)Height);

早些时候我对玩家的昵称做了类似的事情。

nick_steam.Text = SteamFriends.GetPersonaName(); 
4

1 回答 1

1

来自 Steamworks github:

https://github.com/rlabrecque/Steamworks.NET-Test/blob/master/Assets/Scripts/SteamUtilsTest.cs

public static Texture2D GetSteamImageAsTexture2D(int iImage) {
    Texture2D ret = null;
    uint ImageWidth;
    uint ImageHeight;
    bool bIsValid = SteamUtils.GetImageSize(iImage, out ImageWidth, out ImageHeight);

    if (bIsValid) {
        byte[] Image = new byte[ImageWidth * ImageHeight * 4];

        bIsValid = SteamUtils.GetImageRGBA(iImage, Image, (int)(ImageWidth * ImageHeight * 4));
        if (bIsValid) {
            ret = new Texture2D((int)ImageWidth, (int)ImageHeight, TextureFormat.RGBA32, false, true);
            ret.LoadRawTextureData(Image);
            ret.Apply();
        }
    }

    return ret;
}
于 2018-04-03T15:49:03.617 回答