In leaderboard we can upload user's Names but isn't there anyway to upload user's profile pics
I mean I saw a variable named Extra but when send my string (basically a base64 string converted from a sprite) but the problem is that the characters of that string are more than 700 but the allowed amount of characters of that Extra variable is 100
I have tried reducing the quality of that sprite and convert it to jpeg instead of png but still the characters are more than 100
What should I do in this case any ideas?
Viewing post in Leaderboard Creator comments
You should not be storing the full sprite in string, you should create some kind of ID for a sprite in a scriptableObject or something and save that in the extras. I created a little class that helps me store data in a single string in a KvP way, hope it helps:
public class SingleStringKvP { private readonly Dictionary<string, string> _kvPairs = new(); private const char PairSeparator = ';'; private const char KeyValueSeparator = ':'; public SingleStringKvP(string startingValue) { Parse(startingValue); } public SingleStringKvP() { } public void AddValue(string key, string value) { _kvPairs[key] = value; } public string GetValue(string key) { return _kvPairs.TryGetValue(key, out var value) ? value : string.Empty; } public override string ToString() { var builder = new StringBuilder(); foreach (var kvp in _kvPairs) { if (builder.Length > 0) builder.Append(PairSeparator); builder.Append($"{kvp.Key}{KeyValueSeparator}{kvp.Value}"); } return builder.ToString(); } private void Parse(string startingValue) { if (string.IsNullOrEmpty(startingValue)) return; var pairs = startingValue.Split(PairSeparator); foreach (var pair in pairs) { var kv = pair.Split(KeyValueSeparator); if (kv.Length == 2) { var key = kv[0]; var value = kv[1]; AddValue(key, value); } } } }