Beispiel #1
0
        public static bool TrySetSprite(this Graphic graphic, SpriteCache sc)
        {
            if (!sc)
            {
                return(false);
            }

            if (graphic is Image)
            {
                var img = (Image)graphic;
                if (img.sprite != sc)
                {
                    img.sprite = sc;
                }
                return(true);
            }
            else if (graphic is RawImage)
            {
                var imgRaw = (RawImage)graphic;
                UIExtension.OnSetSprite(imgRaw, sc);
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public static void SetSprite(this RawImage imgRaw, SpriteCache sc)
        {
            if (!imgRaw)
            {
                return;
            }

            if (!sc)
            {
                return;
            }

            UIExtension.OnSetSprite(imgRaw, sc);
        }