[英]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.