zoukankan      html  css  js  c++  java
  • 基于steamworks获取steam用户头像

    查看官网api,使用c++写的,转成c#之后,有个问题就是,图片显示问题

    我们可以获取到一个含有图片信息的byte[]

    然后

    private Texture2D downloadedAvatar;
    public RawImage image;
    
    
    downloadedAvatar = new Texture2D((int) width, (int) height, TextureFormat.RGBA32, false);
                        downloadedAvatar.LoadRawTextureData(avatarStream);
                        downloadedAvatar.Apply();
    
                        image.texture = downloadedAvatar;
    Texture2D先load,然后Apply就行了



    【完整源码】
        IEnumerator _FetchAcatar(CSteamID id, RawImage ui)
        {
            //获取中等图片,如果获取的是大图片的话,可能获取不到
            var AvatarInt = SteamFriends.GetMediumFriendAvatar(id);
            Debug.Log("AvatarInt" + AvatarInt);
            while (AvatarInt == -1)
            {
                yield return null;
            }
            if (AvatarInt > 0)
            {
                SteamUtils.GetImageSize(AvatarInt, out width, out height);
    
                if (width > 0 && height > 0)
                {
                    byte[] avatarStream = new byte[4 * (int)width * (int)height];
                    SteamUtils.GetImageRGBA(AvatarInt, avatarStream, 4 * (int)width * (int)height);
    
                    downloadedAvatar = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false);
                    downloadedAvatar.LoadRawTextureData(avatarStream);
                    downloadedAvatar.Apply();
    
                    ui.texture = downloadedAvatar;
                }
            }
        }

    一个开源的unity+steam联机方案

    https://zhuanlan.zhihu.com/p/33601024

    【steam用户验证】

    https://api.steampowered.com/ISteamUser/CheckAppOwnership/v2/?key=A182BE6994FEE94C0880A2FB2759E311&format=json&steamid=76561198448857469&appid=776510

  • 相关阅读:
    换行符 CR
    c# 定义的属性名与保留关键字冲突
    Redis 以window 服务启动
    c# Guid.NewGuid().ToString(format
    select 下拉源动态赋值
    html 控制input标签只能输入数字
    HTTP 错误 500.19
    Android debugger 出现提示Connected to the target VM, address: 'localhost:xxxx', transport: 'socket'
    siege--Web性能压测工具
    python+selenium上传文件注意点
  • 原文地址:https://www.cnblogs.com/sanyejun/p/8664729.html
Copyright © 2011-2022 走看看