예제 #1
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);
        }