Example #1
0
        private void InitializeAnimation(XmlLayoutAnimation animation, bool isSoloAnimation = true)
        {
            if (animation.hasValueFrom)
            {
                // set the initial value
                MethodInfo method = GetType().GetMethod("SetInitialValueForCustomAnimation", BindingFlags.Instance | BindingFlags.NonPublic)
                                    .MakeGenericMethod(new Type[] { animation.valueType });
                method.Invoke(this, new object[] { animation });
            }

            // Cache the MethodInfo if it hasn't been cached already
            // (caching it saves a small amount of time in the Update() method)
            if (!m_SetValueForCustomAnimationAtIndex_MethodInfoCache.ContainsKey(animation.valueType))
            {
                m_SetValueForCustomAnimationAtIndex_MethodInfoCache.Add(
                    animation.valueType,
                    GetType().GetMethod("SetValueForCustomAnimationAtIndex", BindingFlags.Instance | BindingFlags.NonPublic)
                    .MakeGenericMethod(new Type[] { animation.valueType }));
            }

            if (isSoloAnimation)
            {
                m_currentAnimation = animation;
            }
        }
Example #2
0
        /// <summary>
        /// Play the next animation in the queue (if there is one)
        /// </summary>
        private void NextAnimation()
        {
            if (m_animationQueue.Count > 0)
            {
                Animate(m_animationQueue.Dequeue());
            }
            else
            {
                m_currentAnimation = null;

                // Pause update calls
                this.enabled = false;
            }
        }
Example #3
0
        /// <summary>
        /// Smoothly animate a property value from one value to another over the specified duration,
        /// using the provided value setter
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="setter"></param>
        /// <returns></returns>
        private void Animate(XmlLayoutAnimationBase animation)
        {
            this.enabled = true;

            if (animation is XmlLayoutAnimation)
            {
                InitializeAnimation(animation as XmlLayoutAnimation);
            }
            else
            {
                var group = animation as XmlLayoutAnimationGroup;

                foreach (var childAnimation in group.animations)
                {
                    InitializeAnimation(childAnimation, false);
                }

                m_currentAnimation = group;
            }
        }