예제 #1
0
 private static float ParseFrameSecond(Material m, TexProp prop)
 {
     if (m.HasProperty(prop.PropFPSId))
     {
         var val = m.GetFloat(prop.PropFPSId);
         if (val > 0)
         {
             return(1 / val);
         }
     }
     return(settings.defaultFrameSecond);
 }
 // Token: 0x0600041B RID: 1051 RVA: 0x00023BB8 File Offset: 0x00021DB8
 private static float ParseFrameSecond(Material m, TexProp prop)
 {
     if (m.HasProperty(prop.PropFPSId))
     {
         float @float = m.GetFloat(prop.PropFPSId);
         if (@float > 0f)
         {
             return(1f / @float);
         }
     }
     return(ParseAnimUtil.settings.defaultFrameSecond);
 }
예제 #3
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);
        }
예제 #4
0
 public static bool TryGetTargetTex(Material m, TexProp texType, out Texture tex)
 {
     tex = (texType == TexProp.MainTex)? m.mainTexture : m.GetTexture(texType.PropId);
     return(tex != null && IsTarget(tex));
 }
예제 #5
0
        public static bool HasTargetTexName(Material m, TexProp texType)
        {
            var tex = (texType == TexProp.MainTex)? m.mainTexture : m.GetTexture(texType.PropId);

            return(tex != null && IsTarget(tex));
        }
 // 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);
 }
        // Token: 0x0600041D RID: 1053 RVA: 0x00023C10 File Offset: 0x00021E10
        public static bool HasTargetTexName(Material m, TexProp texType)
        {
            Texture texture = (texType == TexProp.MainTex) ? m.mainTexture : m.GetTexture(texType.PropId);

            return(texture != null && ParseAnimUtil.IsTarget(texture));
        }