Exemple #1
0
        public static AnimTex ParseAnimTex(Material mate, TexProp texProp, Texture tex = null)
        {
            try {
                if (tex != null)
                {
                    if (!IsTarget(tex))
                    {
                        return(null);
                    }
                }
                else
                {
                    if (!TryGetTargetTex(mate, texProp, out tex))
                    {
                        return(null);
                    }
                }

                var scale = (texProp == TexProp.MainTex)? mate.mainTextureScale : mate.GetTextureScale(texProp.PropId);
                if (mate.HasProperty(texProp.PropScrollXId) || mate.HasProperty(texProp.PropScrollYId))
                {
                    Vector2 scroll;
                    scroll.x = fitting(mate.GetFloat(texProp.PropScrollXId));
                    scroll.y = fitting(mate.GetFloat(texProp.PropScrollYId));
                    var frameSecond = ParseFrameSecond(mate, texProp);
                    var animTex     = new ScrollTex(scroll, tex, frameSecond)
                    {
                        texProp = texProp
                    };

                    animTex.InitOffsetIndex(mate.GetTextureOffset(texProp.PropId));
                    return(animTex);
                }

                if (scale.x <= 0.5f || scale.y <= 0.5f)
                {
                    if (Equals(scale.x, 0) || Equals(scale.y, 0))
                    {
                        return(null);
                    }

                    var frameSecond = ParseFrameSecond(mate, texProp);
                    var animTex     = new SlideScaledTex(scale, tex, frameSecond)
                    {
                        texProp = texProp
                    };

                    if (animTex.imageLength > 1)
                    {
                        animTex.InitOffsetIndex(mate.GetTextureOffset(texProp.PropId));
                        LogUtil.DebugF("{0} X:{1},Y:{2},length={3}", texProp, animTex.ratioX, animTex.ratioY, animTex.imageLength);
                        return(animTex);
                    }
                    return(animTex);
                }
            } catch (Exception e) {
                // シェーダに未対応テクスチャが設定される場合などではNullRefが発生するため、スルー
                LogUtil.Debug("Failed to parse texture:", texProp, e);
            }
            return(null);
        }
 // Token: 0x06000419 RID: 1049 RVA: 0x0002398C File Offset: 0x00021B8C
 public static AnimTex ParseAnimTex(Material mate, TexProp texProp, Texture tex = null)
 {
     try
     {
         if (tex != null)
         {
             if (!ParseAnimUtil.IsTarget(tex))
             {
                 return(null);
             }
         }
         else if (!ParseAnimUtil.TryGetTargetTex(mate, texProp, out tex))
         {
             return(null);
         }
         Vector2 scale = (texProp == TexProp.MainTex) ? mate.mainTextureScale : mate.GetTextureScale(texProp.PropId);
         if (mate.HasProperty(texProp.PropScrollXId) || mate.HasProperty(texProp.PropScrollYId))
         {
             Vector2 scroll;
             scroll.x = ParseAnimUtil.fitting(mate.GetFloat(texProp.PropScrollXId));
             scroll.y = ParseAnimUtil.fitting(mate.GetFloat(texProp.PropScrollYId));
             float     frameSec  = ParseAnimUtil.ParseFrameSecond(mate, texProp);
             ScrollTex scrollTex = new ScrollTex(scroll, tex, frameSec)
             {
                 texProp = texProp
             };
             scrollTex.InitOffsetIndex(mate.GetTextureOffset(texProp.PropId));
             return(scrollTex);
         }
         if (scale.x <= 0.5f || scale.y <= 0.5f)
         {
             if (ParseAnimUtil.Equals(scale.x, 0f, 1E-06f) || ParseAnimUtil.Equals(scale.y, 0f, 1E-06f))
             {
                 return(null);
             }
             float          frameSec2      = ParseAnimUtil.ParseFrameSecond(mate, texProp);
             SlideScaledTex slideScaledTex = new SlideScaledTex(scale, tex, frameSec2)
             {
                 texProp = texProp
             };
             if (slideScaledTex.imageLength > 1)
             {
                 slideScaledTex.InitOffsetIndex(mate.GetTextureOffset(texProp.PropId));
                 LogUtil.DebugF("{0} X:{1},Y:{2},length={3}", new object[]
                 {
                     texProp,
                     slideScaledTex.ratioX,
                     slideScaledTex.ratioY,
                     slideScaledTex.imageLength
                 });
                 return(slideScaledTex);
             }
             return(slideScaledTex);
         }
     }
     catch (Exception ex)
     {
         LogUtil.Debug(new object[]
         {
             "Failed to parse texture:",
             texProp,
             ex
         });
     }
     return(null);
 }