public IAnimator this[string propertyPath, string animationId = null] { get { IAnimator animator; if (TryFind(propertyPath, out animator, animationId)) { return(animator); } var(p, _, _) = AnimationUtils.GetPropertyByPath(owner, propertyPath); var pi = p.Info; if (pi == null) { throw new Lime.Exception("Unknown property {0} in {1}", propertyPath, owner.GetType().Name); } animator = AnimatorRegistry.Instance.CreateAnimator(pi.PropertyType); animator.TargetPropertyPath = propertyPath; animator.AnimationId = animationId; Add(animator); #if TANGERINE Version++; #endif // TANGERINE owner.OnAnimatorCollectionChanged(); return(animator); } }
private void Bind() { var(p, animable, index) = AnimationUtils.GetPropertyByPath(Owner, TargetPropertyPath); var mi = p.Info?.GetSetMethod(); IsZombie = animable == null || mi == null || p.Info.PropertyType != typeof(T) || animable is IList list && index >= list.Count; if (IsZombie) { return; } Animable = animable; IsTriggerable = p.Triggerable; if (index == -1) { setter = (SetterDelegate)Delegate.CreateDelegate(typeof(SetterDelegate), animable, mi); } else { var indexedSetter = (IndexedSetterDelegate)Delegate.CreateDelegate(typeof(IndexedSetterDelegate), animable, mi); setter = (v) => { indexedSetter(index, v); }; } }