コード例 #1
0
        public static bool Prefix(Localizer __instance)
        {
            var maskableGraphics = __instance.GetComponents <MaskableGraphic>();

            __instance.translation = __instance.stringKey.Translate();
            foreach (var graphic in maskableGraphics)
            {
                if (graphic is Text text)
                {
                    text.text = __instance.translation;
                }
                else if (graphic is Image image)
                {
                    if (IsUri(__instance.translation))
                    {
                        __instance.StartCoroutine(GetRequest(__instance.translation, image));
                    }
                    else
                    {
                        image.sprite = Resources.Load <Sprite>(__instance.translation);
                    }
                }
                else if (graphic is RawImage rawImage)
                {
                    if (IsUri(__instance.translation))
                    {
                        __instance.StartCoroutine(GetRequest(__instance.translation, rawImage));
                    }
                    else
                    {
                        rawImage.texture = Resources.Load <Texture2D>(__instance.translation);
                    }
                }
            }

            return(false);
        }