Ejemplo n.º 1
0
        public void OnImage(Facepunch.Steamworks.Image image)
        {
            if (image.IsError)
            {
                //Debug.Log("Failed to load avatar of user " + steamID + ". Trying again...");
                Facepunch.Steamworks.Client.Instance.Friends.GetAvatar(Facepunch.Steamworks.Friends.AvatarSize.Large, steamID, OnImage);
            }
            else
            {
                Texture2D texture = new Texture2D(image.Width, image.Height);

                for (int x = 0; x < image.Width; x++)
                {
                    for (int y = 0; y < image.Height; y++)
                    {
                        Facepunch.Steamworks.Color c = image.GetPixel(x, y);
                        texture.SetPixel(x, image.Height - y, new Color(c.r / 255.0f, c.g / 255.0f, c.b / 255.0f, c.a / 255.0f));
                    }
                }

                texture.Apply();

                avatar.sprite = Sprite.Create(texture, new Rect(0, 0, image.Width, image.Height), Vector2.zero);
            }
        }
Ejemplo n.º 2
0
        private void OnImage(Facepunch.Steamworks.Image image)
        {
            if (image == null)
            {
                Debug.LogWarning("Failed to get avatar.");
                return;
            }

            var texture = new Texture2D(image.Width, image.Height);

            for (int x = 0; x < image.Width; x++)
            {
                for (int y = 0; y < image.Height; y++)
                {
                    var p = image.GetPixel(x, y);

                    texture.SetPixel(x, image.Height - y, new UnityEngine.Color(p.r / 255.0f, p.g / 255.0f, p.b / 255.0f, p.a / 255.0f));
                }
            }

            texture.Apply();

            ApplyTexture(texture);
        }