using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using sam; public class OrbitsController : MonoBehaviour { public Material orbitMaterial; public Color defaultColor = Color.yellow; public Color selectedColor = Color.red; public float lineWidth = 0.65f; OrbitSelectSubsession oss; Satellite satellite; List satControllers = new List(); SatelliteOrbitController selectedOrbit = null; private void Awake() { oss = GetComponentInParent(); } public void OnProductListUpdated(List productNames) { satControllers.Clear(); satellite = new Satellite(oss.cfg.tleHistoryFilename, oss.cfg.satelliteId); int n = productNames.Count; for (int i=0; i(); satControllers.Add(soc); //soc.gameObject.AddComponent(); soc.transform.SetParent(transform); soc.satellite = satellite; soc.orbitStartDateTime = oss.productDates[i].Item1.ToString("yyyy-MM-ddTHH:mm:ss"); soc.orbitEndDateTime = oss.productDates[i].Item2.ToString("yyyy-MM-ddTHH:mm:ss"); soc.width = 0.01f; soc.orbitMaterial = orbitMaterial; } } private IEnumerator Start() { while (satControllers.Count == 0) yield return null; bool ready = false; SatelliteOrbitController soc = satControllers[0]; while (!ready) { yield return null; ready = soc.GetComponentInChildren() != null; } if (selectedOrbit == null) selectedOrbit = soc; foreach (var orbit in satControllers) { LineRenderer r = orbit.GetComponentInChildren(); r.startWidth = lineWidth; r.endWidth = lineWidth; if (selectedOrbit == orbit) { r.startColor = selectedColor; r.endColor = selectedColor; } else { r.startColor = defaultColor; r.endColor = defaultColor; } } } public void OnOrbitSelected((string name, (DateTime start, DateTime end) dates) product) { if (selectedOrbit != null) { LineRenderer lr = selectedOrbit.GetComponentInChildren(); lr.startColor = defaultColor; lr.endColor = defaultColor; } SatelliteOrbitController soc = satControllers[oss.selectedProductIndex]; LineRenderer r = soc.GetComponentInChildren(); if (r != null) { r.startColor = selectedColor; r.endColor = selectedColor; } selectedOrbit = soc; } }