Esempio n. 1
0
        private static void InstallAnimations(RectTransformElement rte, GameObject gameObject, IReadOnlyLayoutContext context)
        {
            AnimationContext animationContext = new AnimationContext();

            List <(UIAnimation, AnimationElement)> listOfAnimations = new List <(UIAnimation, AnimationElement)>();

            foreach (var anim in rte.Animations)
            {
                var         constructor = Constructors.GetAnimationConstructor(anim);
                UIAnimation animation   = constructor.Install(gameObject, anim, context);

                if (!string.IsNullOrEmpty(anim.Key))
                {
                    animationContext.AddAnimation(context.ParseString(anim.Key), animation);
                }

                listOfAnimations.Add((animation, anim));
            }

            foreach (var pair in listOfAnimations)
            {
                var anim      = pair.Item2;
                var animation = pair.Item1;
                foreach (var trigger in anim.Triggers)
                {
                    var       constructor      = Constructors.GetTriggerConstructor(trigger);
                    UITrigger triggerComponent = constructor.Install(gameObject, trigger, context, animationContext);

                    triggerComponent.conditions = ParseConditions(trigger.Conditions, gameObject, context);
                    triggerComponent.instant    = context.ParseBool(trigger.Instant);
                    triggerComponent.animation  = animation;
                }
            }
        }