Пример #1
0
        public void DerivedPathWorks()
        {
            var derivedPath = new DerivedPath("foo");

            Assert.True(derivedPath.DoStuff());
            Assert.True(derivedPath.Parent().DoStuff());
        }
Пример #2
0
    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());
            }
        }
    }
Пример #3
0
    private string GuessTrackName(DerivedPath path)
    {
        var track = path.GetComponentInParent <Track>();

        if (track)
        {
            return(track.Name.ToLower());
        }
        return(SceneManager.GetActiveScene().name.ToLower());
    }
Пример #4
0
    // 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);
    }
Пример #5
0
    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);
                }
            }
        }
    }