Animating DependencyProperty
Hello,
i am running into an error when i try to animate a dependency property.
I want to expose predefined render transforms to the user of the control through dependency properties.
The user can then define a storyboard to animate this properties.
In the code behind i have something like this:
The storyboard looks like this:
In Unity i get the following errors:
[noesis] Can't animate 'Double' value with a DoubleAnimation
UnityEngine.Debug:LogError(Object)
NoesisUnity:UnityLog(Int32, String) (at Assets/NoesisGUI/Plugins/NoesisUnity.cs:116)
Noesis.View:Noesis_View_Update(HandleRef, Double)
Noesis.View:Update(Double) (at Assets/NoesisGUI/Plugins/API/Core/View.cs:271)
NoesisView:LateUpdate() (at Assets/NoesisGUI/Plugins/NoesisView.cs:822)
[noesis] Can't animate property 'NoesisGui.Assets.Scripts.GuiUtility.Controls.AnimatedTextBlock.ScaleX' with a DoubleAnimation
UnityEngine.Debug:LogError(Object)
NoesisUnity:UnityLog(Int32, String) (at Assets/NoesisGUI/Plugins/NoesisUnity.cs:116)
Noesis.View:Noesis_View_Update(HandleRef, Double)
Noesis.View:Update(Double) (at Assets/NoesisGUI/Plugins/API/Core/View.cs:271)
NoesisView:LateUpdate() (at Assets/NoesisGUI/Plugins/NoesisView.cs:822)
Am i doing something wrong or do i miss something?
i am running into an error when i try to animate a dependency property.
I want to expose predefined render transforms to the user of the control through dependency properties.
The user can then define a storyboard to animate this properties.
In the code behind i have something like this:
Code: Select all
public static readonly DependencyProperty ScaleXProperty = DependencyProperty.Register(
"ScaleX", typeof(double), typeof(AnimatedTextBlock), new PropertyMetadata(1d));
public double ScaleX
{
get { return (double)GetValue(ScaleXProperty); }
set { SetValue(ScaleXProperty, value); }
}
Code: Select all
<Storyboard x:Key="Storyboard">
<DoubleAnimation Storyboard.TargetProperty="(controls1:AnimatedTextBlock.ScaleX)"
From="2" To="1" Duration="0:0:0.5"/>
</Storyboard>
[noesis] Can't animate 'Double' value with a DoubleAnimation
UnityEngine.Debug:LogError(Object)
NoesisUnity:UnityLog(Int32, String) (at Assets/NoesisGUI/Plugins/NoesisUnity.cs:116)
Noesis.View:Noesis_View_Update(HandleRef, Double)
Noesis.View:Update(Double) (at Assets/NoesisGUI/Plugins/API/Core/View.cs:271)
NoesisView:LateUpdate() (at Assets/NoesisGUI/Plugins/NoesisView.cs:822)
[noesis] Can't animate property 'NoesisGui.Assets.Scripts.GuiUtility.Controls.AnimatedTextBlock.ScaleX' with a DoubleAnimation
UnityEngine.Debug:LogError(Object)
NoesisUnity:UnityLog(Int32, String) (at Assets/NoesisGUI/Plugins/NoesisUnity.cs:116)
Noesis.View:Noesis_View_Update(HandleRef, Double)
Noesis.View:Update(Double) (at Assets/NoesisGUI/Plugins/API/Core/View.cs:271)
NoesisView:LateUpdate() (at Assets/NoesisGUI/Plugins/NoesisView.cs:822)
Am i doing something wrong or do i miss something?
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Animating DependencyProperty
That error is happening because in Noesis our API uses floats and to be compatible with WPF we made the DoubleAnimation/DoubleAnimationUsingKeyFrames to animate float values.
If you change your properties to be float the animation should work fine.
If you change your properties to be float the animation should work fine.
Code: Select all
public static readonly DependencyProperty ScaleXProperty = DependencyProperty.Register(
"ScaleX", typeof(float), typeof(AnimatedTextBlock), new PropertyMetadata(1.0f));
public float ScaleX
{
get { return (float)GetValue(ScaleXProperty); }
set { SetValue(ScaleXProperty, value); }
}
Re: Animating DependencyProperty
Thanks for the Answer. I will keep that in mind.
I worked around the problem by exposing the whole transforms (ScaleTransform, RotateTransform,...) as DependencyProperties.
I worked around the problem by exposing the whole transforms (ScaleTransform, RotateTransform,...) as DependencyProperties.
Re: Animating DependencyProperty
Thanks a lot for your feedback!
Who is online
Users browsing this forum: Google [Bot] and 81 guests