public void DerivedPathWorks() { var derivedPath = new DerivedPath("foo"); Assert.True(derivedPath.DoStuff()); Assert.True(derivedPath.Parent().DoStuff()); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("Resolution")); if (target is InterpolatedPath) { EditorGUILayout.PropertyField(serializedObject.FindProperty("coefficient")); } if (target is NamedPath) { EditorGUILayout.PropertyField(serializedObject.FindProperty("Name")); } serializedObject.ApplyModifiedProperties(); DerivedPath path = (target as DerivedPath); if (GUILayout.Button("Generate")) { Undo.RecordObject(path, "Reinitialise Path"); path.Initialise(); } EditorGUI.BeginDisabledGroup(path.waypoints.Count <= 0); if (GUILayout.Button("Export Sections")) { ExportSections(path.GetSections()); } if (GUILayout.Button("Export Observations")) { ExportObservations(path); } if (GUILayout.Button("Load")) { Undo.RecordObject(path, "Load Path"); path.Load(ImportWeights()); } EditorGUI.EndDisabledGroup(); EditorGUILayout.LabelField("Waypoints", path.waypoints.Count.ToString()); EditorGUILayout.LabelField("Length", path.totalLength.ToString()); if (target is InterpolatedPath) { var ip = (target as InterpolatedPath); if (ip.crossoverPoints != null) { EditorGUILayout.LabelField("Crossovers", ip.crossoverPoints.Count.ToString()); } } }
private string GuessTrackName(DerivedPath path) { var track = path.GetComponentInParent <Track>(); if (track) { return(track.Name.ToLower()); } return(SceneManager.GetActiveScene().name.ToLower()); }
// Start is called before the first frame update void Start() { path = navigator.waypoints as DerivedPath; if (path == null) { this.enabled = false; return; } profile = new Profile(path.waypoints.Count); }
private void ExportObservations(DerivedPath path) { var filename = EditorUtility.SaveFilePanel("Save Observations", "", (GuessTrackName(path) + ".observations"), "txt"); if (filename.Length != 0) { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(filename)) { for (float d = 0; d < path.totalLength; d++) { var q = path.Query(d); writer.WriteLine(d); writer.WriteLine(q.Curvature); writer.WriteLine(q.Camber); writer.WriteLine(q.Inclination); } } } }