Set Data of path in code
Posted: 17 Jul 2015, 08:28
How do I do this in Unity C#?
The Data part has to be changed dynamically. Parse is not supported.
Edit:
This works, but it crashes NoesisGUI, and then the Editor:
Code: Select all
Path arcPath = new Path();
arcPath.Stroke = new SolidColorBrush(Colors.Blue);
arcPath.StrokeThickness = 1;
arcPath.Data = Geometry.Parse("M 80,200 A 100,50 45 1 0 100,50 Z");
Edit:
This works, but it crashes NoesisGUI, and then the Editor:
Code: Select all
using UnityEngine;
using System.Collections;
using Noesis;
public class ND : MonoBehaviour {
Path path;
float point0 = 0;
void Start (){
NoesisGUIPanel panel = GetComponent<NoesisGUIPanel>();
FrameworkElement root = panel.GetContent();
root.Parent.UseLayoutRounding = false;
Noesis.Canvas canvas = (Noesis.Canvas)root.FindName("layer1");
path = new Path();
path.Stroke = new SolidColorBrush(Colors.Green);
path.StrokeThickness = 1;
canvas.Children.Add(path);
}
void Update(){
point0 = (Mathf.Sin(Time.time * 0.5f) * 30f) + 30;
string pathString = "M 17.57812541,76.56250172 62.22098358,83.25893044 81.75223403,68.47098367 80.35714471," + point0;
path.SetBinding(Path.DataProperty, new Binding(){Source=pathString});
}
}