private void CombineStateFromAnimations(double animationTime, ElementSave element, ref StateSave stateToSet) { var animationKeyframes = this.Keyframes.Where(item => item.SubAnimationViewModel != null && item.Time <= animationTime); foreach (var keyframe in animationKeyframes) { var subAnimationElement = element; string instanceName = null; if (keyframe.AnimationName.Contains('.')) { instanceName = keyframe.AnimationName.Substring(0, keyframe.AnimationName.IndexOf('.')); InstanceSave instance = element.Instances.FirstOrDefault(item => item.Name == instanceName); if (instance != null) { subAnimationElement = Gum.Managers.ObjectFinder.Self.GetElementSave(instance); } } var relativeTime = animationTime - keyframe.Time; var stateFromAnimation = keyframe.SubAnimationViewModel.GetStateToSet(relativeTime, element, false); if (stateFromAnimation != null) { if (subAnimationElement != element) { foreach (var variable in stateFromAnimation.Variables) { variable.Name = instanceName + "." + variable.Name; } } stateToSet.MergeIntoThis(stateFromAnimation, 1); } } }