Exemple #1
0
        public static GameObject GeneratePlayerIcon(Player p, GameObject iconPrefab, GameObject fallbackPrefab)
        {
            GameObject obj     = PlayerIcon.CreatePlayerIcon(p, iconPrefab);
            GameObject target  = obj.transform.GetChild(0).gameObject;
            bool       success = PlayerIcon.LoadSprite(p.Position.IconURL, target);

            if (!success)
            {
                GameObject.Destroy(obj);
                LogManager.Warn($"Unable to load player icons for PlayerId {p.Id}, falling back to abstract");
                obj = GeneratePlayerIconAbstract(p, fallbackPrefab);
            }
            return(obj);
        }
Exemple #2
0
        public static GameObject GeneratePlayerIconAbstract(Player p, GameObject prefab)
        {
            GameObject obj = PlayerIcon.CreatePlayerIcon(p, prefab);

            // Set Background color
            var            child     = obj.transform.GetChild(0).gameObject;
            SpriteRenderer renderer  = child.GetComponent <SpriteRenderer>();
            string         c0        = p.IsHome ? FFB.Instance.Settings.Color.HomeColor : FFB.Instance.Settings.Color.AwayColor;
            bool           parseable = ColorUtility.TryParseHtmlString(c0, out Color c1);

            if (parseable)
            {
                renderer.color = c1;
            }
            ;

            // Set text
            TMPro.TextMeshPro text = obj.GetComponentInChildren <TMPro.TextMeshPro>();
            text.text = p.Position?.AbstractLabel ?? "*";
            return(obj);
        }