// ReSharper disable once UnusedMember.Local private void Update() { if (!IsInitialized) { return; } Profiler.BeginSample("SteamClient.RunCallbacks"); SteamAPI.RunCallbacks(); Profiler.EndSample(); Profiler.BeginSample("SteamAvatarCache.Cycle"); SteamAvatarCache.Cycle(); Profiler.EndSample(); Profiler.BeginSample("SteamNetworking.P2P"); uint DataAvailable = 0; while (SteamNetworking.IsP2PPacketAvailable(out DataAvailable)) { var dest = new byte[DataAvailable]; CSteamID steamid; if (SteamNetworking.ReadP2PPacket(dest, DataAvailable, out DataAvailable, out steamid)) { ProcessSteamNetworkingPacket(dest, steamid); } } Profiler.EndSample(); }
public static Texture FindTexture(ulong steamid) { var found = _avatars.Find(x => x._steamid == steamid); if (found != null) { return(found._texture); } var created = new SteamAvatarCache() { _texture = new Texture2D(64, 64, TextureFormat.ARGB32, false), _steamid = steamid, _imageId = SteamFriends.GetMediumFriendAvatar(new CSteamID(steamid)) }; created._texture.filterMode = FilterMode.Trilinear; created._texture.wrapMode = TextureWrapMode.Clamp; created._texture.anisoLevel = 8; for (int x = 0; x < created._texture.width; x++) { for (int y = 0; y < created._texture.height; y++) { created._texture.SetPixel(x, y, new Color32(0, 0, 0, 255)); } } created._texture.Apply(); _avatars.Add(created); _avatarsLoading.Add(created); created.Load(); return(created._texture); }
public static Texture GetAvatarTexture(ulong steamid) { SteamFriends.RequestUserInformation(new CSteamID(steamid), false); return(SteamAvatarCache.FindTexture(steamid)); }