Programmatic Storyboard Creation
Posted: 18 Oct 2023, 16:47
I'm getting this warning, but I am not sure what it means.
I tried making the storyboard controllable via the overload, but the warning persists. Is there something I can do to avoid creating this wanring?
Code: Select all
[NOESIS/W] Can't Stop Storyboard, it was initiated with a different Target
UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
NoesisUnity:UnityLog (int,string) (at D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/NoesisUnity.cs:355)
Noesis.Storyboard:Stop () (at D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/API/Proxies/Storyboard.cs:193Code: Select all
public static Storyboard ResizeHeight(this FrameworkElement frameworkElement, FrameworkElement parent, float height, TimeSpan duration, Action completed = null)
{
if (parent == null)
throw new NullReferenceException("parent");
if (BaseComponent.getCPtr(parent).Handle == IntPtr.Zero)
throw new NullReferenceException("parent");
string key = "Resize" + frameworkElement.GetHashCode();
StopStoryboard(key, parent);
if (parent.Resources.Contains(key))
{
UnityEngine.Debug.LogWarning("Resource already exists");
return null;
}
DoubleAnimation animation = new DoubleAnimation();
animation.Duration = new Duration(duration);
animation.AutoReverse = false;
animation.FillBehavior = FillBehavior.Stop;
Storyboard storyboard = new Storyboard();
storyboard.AutoReverse = false;
storyboard.Duration = animation.Duration;
storyboard.FillBehavior = FillBehavior.Stop;
storyboard.Children.Add(animation);
parent.Resources.Add(key, storyboard);
Storyboard.SetTarget(animation, frameworkElement);
Storyboard.SetTargetProperty(animation, new PropertyPath("Height"));
animation.From = frameworkElement.Height;
animation.To = height.Value;
storyboard.Completed += (sender2, e2) =>
{
parent.Resources.Remove(key);
frameworkElement.Height = height.Value;
completed?.Invoke();
};
storyboard.Begin();
return storyboard;
}