[英]How to get steam avatar with steamworks in c#?
我正在c#.NET中编程, 我没有使用Unity ,而是希望通过Steamworks收集玩家的头像并将其放置在PictureBox中。 我做了些什么,但不知道下一步是什么。 我是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();
从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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.