Exemple #1
0
        public static void OnTranslateSprite(ref Sprite sprite)
        {
            if (sprite == null)
            {
                return;
            }

            string spriteName = sprite.name;
            bool   previouslyTranslated;

            if (string.IsNullOrEmpty(spriteName) || (previouslyTranslated = spriteName.StartsWith("!")))
            {
                return;
            }

            TextureTranslationEventArgs args = new TextureTranslationEventArgs(sprite.name, "SPRITE")
            {
                OriginalTexture = sprite.texture
            };

            SpriteLoad?.Invoke(null, args);

            if (args.Data == null)
            {
                return;
            }

            Sprite newSprite = Sprite.Create(args.Data.CreateTexture2D(), sprite.rect, sprite.pivot);

            newSprite.name = previouslyTranslated ? spriteName : "!" + spriteName;
            sprite         = newSprite;
        }
Exemple #2
0
        public static TextureResource OnArcTextureLoaded(TextureResource resource, string name)
        {
            TextureTranslationEventArgs args = new TextureTranslationEventArgs(name, "ARC")
            {
                Data = resource
            };

            ArcTextureLoaded?.Invoke(null, args);

            return(resource);
        }
Exemple #3
0
        public static bool OnArcTextureLoad(out TextureResource result, string name)
        {
            name = name.Replace(".tex", "");

            TextureTranslationEventArgs args = new TextureTranslationEventArgs(name, "ARC");

            ArcTextureLoad?.Invoke(null, args);

            result = args.Data;
            return(args.Data != null);
        }
Exemple #4
0
        public static void OnAssetTextureLoad(int forceTag, UIWidget im)
        {
            bool      force = forceTag != 0;
            Texture2D texture2D;

            if ((texture2D = im.material?.mainTexture as Texture2D) == null)
            {
                return;
            }

            string textureName = texture2D.name;

            if (string.IsNullOrEmpty(textureName))
            {
                return;
            }
            if (textureName.StartsWith("!"))
            {
                if (!force)
                {
                    return;
                }
                texture2D.name = texture2D.name.Substring(1);
            }

            TextureTranslationEventArgs args = new TextureTranslationEventArgs(textureName, im.name)
            {
                OriginalTexture = texture2D
            };

            AssetTextureLoad?.Invoke(im, args);

            if (args.Data == null)
            {
                return;
            }

            texture2D.name = "!" + textureName;
            texture2D.LoadImage(EmptyTextureData);
            texture2D.LoadImage(args.Data.data);
        }
        private static void TranslateAssetTexture(bool force, Texture2D texture2D, UIWidget im)
        {
            if (texture2D == null)
            {
                return;
            }

            string textureName = texture2D.name;

            if (string.IsNullOrEmpty(textureName))
            {
                return;
            }
            if (textureName.StartsWith("!"))
            {
                if (!force)
                {
                    return;
                }
                texture2D.name = texture2D.name.Substring(1);
            }

            var args = new TextureTranslationEventArgs(textureName, im.name)
            {
                OriginalTexture = texture2D
            };

            AssetTextureLoad?.Invoke(im, args);

            if (args.Data == null)
            {
                return;
            }

            texture2D.name = "!" + textureName;
            texture2D.LoadImage(EmptyTextureData);
            texture2D.LoadImage(args.Data.data);
        }