private void Awake() { // We put the trail object under the planet, but we want it to be the parented to the parent of the planet ... // which will be the solar system planet = GetComponentInParent <OrbitUpdater>(); container = new GameObject("Orbit Container " + planet.name); var planetTransform = planet.transform; container.transform.SetParent(planetTransform.parent, worldPositionStays: false); FindSunIfNeeded(); container.AddComponent <NoAutomaticFade>(); List <Vector3> realPositions, schematicPositions; GeneratePositionsForOrbit(out realPositions, out schematicPositions); var orbitsRenderer = OrbitsRenderer.GetOrCreate(planet.transform.parent); orbitsRenderer.AddOrbit(this, realPositions, schematicPositions); originalGlobalScale = orbitMaterial.GetFloat("_GlobalScale"); orbitsRenderer.orbitsMaterial = orbitMaterial; }
// Following functionality is very expensive and doesnt really need to happen in awake so delay it a bit to reduce the transition overhead private IEnumerator AwakeCoroutine() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); List <Vector3> realPositions, schematicPositions; GeneratePositionsForOrbit(out realPositions, out schematicPositions); var orbitsRenderer = OrbitsRenderer.GetOrCreate(Planet.transform.parent); orbitsRenderer.AddOrbit(this, realPositions, schematicPositions); originalGlobalScale = orbitMaterial.GetFloat("_GlobalScale"); originalWidth = orbitMaterial.GetFloat("_Width"); if (GalaxyExplorerManager.IsImmersiveHMD) { orbitMaterial.SetFloat("_Width", GalaxyExplorerManager.OrbitalTrailFixedWidth); } orbitsRenderer.orbitsMaterial = orbitMaterial; }