zyzyx
Topic Author
Posts: 19
Joined: 13 Aug 2014, 13:19

[Unity] Setting GridLength in Storyboard

18 Sep 2014, 10:57

Hi,

I'm trying to set the Width/Height of Row/ColumnDefinition of a Grid in a VisualState:
<VisualState x:Name="Landscape">
    <Storyboard>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="col1" 
                                       Storyboard.TargetProperty="Width">
            <DiscreteObjectKeyFrame KeyTime="0">
                <DiscreteObjectKeyFrame.Value>
                    <GridLength>3*</GridLength>
                </DiscreteObjectKeyFrame.Value>
            </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="row1" 
                                       Storyboard.TargetProperty="Height">
            <DiscreteObjectKeyFrame KeyTime="0">
                <DiscreteObjectKeyFrame.Value>
                    <GridLength>*</GridLength>
                </DiscreteObjectKeyFrame.Value>
            </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>
This works with wpf but in unity I get the following error:
[DX9] Assets/_Project/Xaml/GuiTest_2.xaml
Type 'GridLength' is not registered for boxed serialization
UnityEngine.Debug:LogError(Object)
Noesis.BuildToolKernel:OnLog(Int32, String) (at Assets/Editor/NoesisGUI/NoesisBuildToolKernel.cs:194)
System.Object:wrapper_native_27DCA7D0()
Noesis.BuildToolKernel:Build() (at Assets/Editor/NoesisGUI/NoesisBuildToolKernel.cs:140)
NoesisPostProcessor:Build(String, Boolean, Boolean) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:363)
NoesisPostProcessor:Build(Boolean, Boolean) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:329)
NoesisPostProcessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:256)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])
Is this a bug I should report or is this by design?
Is there another way to achive this behavior?
Last edited by zyzyx on 18 Sep 2014, 16:24, edited 1 time in total.
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: [Unity] Setting GridLength in Storyboard

18 Sep 2014, 16:18

It was a bug, will be fixed for the next release.

Meanwhile you will have to change Row/Column definition in code:
ColumnDefinition col = grid.GetColumnDefinitions().Get(0).As<ColumnDefinition>();
col.SetWidth(new GridLength(3.0f, GridUnitType.Star));
 
zyzyx
Topic Author
Posts: 19
Joined: 13 Aug 2014, 13:19

Re: [Unity] Setting GridLength in Storyboard

18 Sep 2014, 16:25

Great, thanks!

Who is online

Users browsing this forum: No registered users and 0 guests