RenderTransform read and write
Posted: 17 Jul 2015, 02:19
In my xaml code I have a RenderTransform which looks like this:
How do I read and write the translation and rotation values in Unity C#?
Edit:
presumably it is something like this:
But I get this error:
Edit 2:
It seems that whether or not you can cast to RotateTransform depends on what is in the xaml file. So I guess I am stuck with using the MatrixTransform. So how do I convert the matrix to a rotation value? Maybe providing a function for that would be helpful.
Code: Select all
<Canvas Name="g4709" RenderTransform="0,1,-1,0,868.716430664063,217.774169921875">Edit:
presumably it is something like this:
Code: Select all
UIElement pitch = (UIElement)root.FindName("g4709");
RotateTransform pitchRotateTransform = new RotateTransform();
pitchRotateTransform = (RotateTransform)pitch.RenderTransform;
float debug = pitchRotateTransform.Angle;
It does cast to a MatrixTransform, but that doesn't contain easy functions for getting the rotation.InvalidCastException: Cannot cast from source type to destination type.
Edit 2:
It seems that whether or not you can cast to RotateTransform depends on what is in the xaml file. So I guess I am stuck with using the MatrixTransform. So how do I convert the matrix to a rotation value? Maybe providing a function for that would be helpful.