Transforming objects by code
Posted: 07 Feb 2015, 01:41
Continuing from my post here:
http://forum.unity3d.com/threads/noesis ... st-1952232
I modified it to this:
This is my xaml:
but circleRotateTransform and circleTranslateTransform are still null.
I noticed another way of transforming objects here:
http://www.noesisengine.com/docs/Gui.Co ... ction.html
What is the difference between the two methods of transforming an object?
I saw an example of the PlaneProjection class in the ControlGallery->Projection example, but I can't figure out how to do this in code, like in my attempt above.
http://forum.unity3d.com/threads/noesis ... st-1952232
I modified it to this:
Code: Select all
using UnityEngine;
using System.Collections;
using Noesis;
public class Controller : MonoBehaviour{
Noesis.UIElement circle;
Noesis.RotateTransform circleRotateTransform;
Noesis.TranslateTransform circleTranslateTransform;
float x = 0;
float y = 0;
float angle = 0;
void Start (){
NoesisGUIPanel panel = GetComponent<NoesisGUIPanel>();
FrameworkElement root = panel.GetRoot<FrameworkElement>();
circle = root.FindName<Noesis.UIElement>("path4152");
Noesis.TransformGroup group = new Noesis.TransformGroup();
group.GetChildren().Add(new Noesis.RotateTransform(angle));
group.GetChildren().Add(new Noesis.TranslateTransform(x, y));
circle.SetRenderTransform(group);
circle.SetRenderTransformOrigin(new Noesis.Point(0.5f, 0.5f));
circleRotateTransform = circle.GetRenderTransform().As<Noesis.RotateTransform>();
circleTranslateTransform = circle.GetRenderTransform().As<Noesis.TranslateTransform>();
}
void Update () {
circleRotateTransform.SetAngle(angle + Time.deltaTime);
circleTranslateTransform.SetX(x + Time.deltaTime);
}
}
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!--This file is compatible with Silverlight-->
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2" Width="744.09448819" Height="1052.3622047">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources>
<LinearGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="linearGradient4154" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="1,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF000000" Offset="0"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Canvas.Resources>
<!--Unknown tag: sodipodi:namedview-->
<!--Unknown tag: metadata-->
<Canvas Name="layer2"/>
<Canvas Name="layer1">
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="rect4235" Fill="#FF000000" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4" Opacity="1" Data="m 1.4277344 -23.351562 0 1068.570362 1105.7148656 0 0 -1068.570362 -1105.7148656 0 z M 493.92773 257.41992 c 164.25234 -0.20785 237.5 138.8711 237.5 138.8711 l 0 267.5 c 0 0 -73.24766 139.49136 -237.5 139.69921 -164.25235 0.20786 -237.5 -139.69921 -237.5 -139.69921 l 0 -267.5 c 0 0 73.24765 -138.66324 237.5 -138.8711 z"/>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path4152" Fill="#FFD40000" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4" Opacity="1" Data="M 355.55816 386.65996 A 205.71428 205.71428 0 0 1 582.56846 205.0325 205.71428 205.71428 0 0 1 764.50291 431.79683 205.71428 205.71428 0 0 1 537.98497 614.03796 205.71428 205.71428 0 0 1 355.43751 387.76681"/>
<Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="121.42857" Canvas.Top="69.505058" Width="135" Height="242.85715" Name="rect4154" Fill="#FFD40000" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4" Opacity="1"/>
</Canvas>
</Canvas>
I noticed another way of transforming objects here:
http://www.noesisengine.com/docs/Gui.Co ... ction.html
What is the difference between the two methods of transforming an object?
I saw an example of the PlaneProjection class in the ControlGallery->Projection example, but I can't figure out how to do this in code, like in my attempt above.