Example #1
0
 public CachedAnimationData(AnimControllerData animData, Texture2D textureAtlas, Rect[] uvs, float[] delays)
 {
     this.animData     = animData;
     this.textureAtlas = textureAtlas;
     this.uvs          = uvs;
     this.delays       = delays;
 }
        public AnimControllerData Register(string textureIndex, Rect[] uvs, float[] delays)
        {
            AnimControllerData newAnim = new AnimControllerData(textureIndex, uvs, delays);

            registeredAnimations.Add(newAnim);
            return(newAnim);
        }
        private void CheckFrame(AnimControllerData animation, DateTime now)
        {
            var difference = now - animation.lastSwitch;

            if (difference.Milliseconds < animation.delays[animation.uvIndex])
            {
                // Frame still has time remaining
                return;
            }

            var cachedTextureData = ImageDownloader.CachedTextures[animation.textureIndex];

            if (cachedTextureData.isDelayConsistent && animation.delays[animation.uvIndex] <= 10 && difference.Milliseconds < 100)
            {
                // Bump animations with consistently 10ms or lower frame timings to 100ms
                return;
            }


            animation.lastSwitch = now;
            do
            {
                animation.uvIndex++;
                if (animation.uvIndex >= animation.uvs.Length)
                {
                    animation.uvIndex = 0;
                }
            }while (!cachedTextureData.isDelayConsistent && animation.delays[animation.uvIndex] == 0);

            Rect uv = animation.uvs[animation.uvIndex];

            cachedTextureData.animInfo.shadowMaterial?.SetVector("_CropFactors", new Vector4(uv.x, uv.y, uv.width, uv.height));
            cachedTextureData.animInfo.imageMaterial?.SetVector("_CropFactors", new Vector4(uv.x, uv.y, uv.width, uv.height));
        }
Example #4
0
        public int Register(string textureIndex, Rect[] uvs, float delay)
        {
            AnimControllerData newAnim = new AnimControllerData(textureIndex, uvs, delay);

            registeredAnimations.Add(newAnim);
            return(registeredAnimations.IndexOf(newAnim));
        }