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; }
public void Init() { info = new float[2]; OrbitUpdater ou = GetComponent <OrbitUpdater>(); if (ou == null) { return; } Vector3 v3 = transform.localPosition; radius_revol = v3.magnitude; startRadian = Mathf.Acos(v3.x / v3.magnitude); if (v3.z < 0) { startRadian *= -1; } //planet.startRadian = 0; radianSpeed_revel = Mathf.PI / ou.Period * scaleFactor; originLocalScale = transform.localScale.x; Destroy(ou); scaleSelect = Vector3.one * originLocalScale * SolarSystem.Instance.selectedScaleFactor * this.planetScaleFactor; scaleNormal = Vector3.one * originLocalScale; selected = false; }