public CoronaLoader(CelestialBody body) { // Is this a spawned body? if (body?.scaledBody == null || Injector.IsInPrefab) { throw new InvalidOperationException("The body must be already spawned by the PSystemManager."); } // We need to get the body for the Sun (to steal it's corona mesh) PSystemBody sun = Utility.FindBody(Injector.StockSystemPrefab.rootBody, "Sun"); // Clone a default Corona GameObject corona = UnityEngine.Object.Instantiate(sun.scaledVersion.GetComponentsInChildren <SunCoronas>(true).First().gameObject) as GameObject; // Backup local transform parameters Vector3 position = corona.transform.localPosition; Vector3 scale = corona.transform.localScale; Quaternion rotation = corona.transform.rotation; // Parent the new corona corona.transform.parent = body.scaledBody.transform; // Restore the local transform settings corona.transform.localPosition = position; corona.transform.localScale = scale; corona.transform.localRotation = rotation; Value = corona.GetComponent <SunCoronas> (); // Setup the material loader material = new ParticleAddSmoothLoader(corona.GetComponent <Renderer>().material); material.name = Guid.NewGuid().ToString(); }
/// <summary> /// Creates a new Corona Loader from an already existing corona /// </summary> public CoronaLoader(SunCoronas component) { Value = component; if (!(Value.GetComponent <Renderer>().material is ParticleAddSmoothLoader)) { material = new ParticleAddSmoothLoader(Value.GetComponent <Renderer>().material); } }
// Default constructor public CoronaLoader() { // We need to get the body for the Sun (to steal it's corona mesh) PSystemBody sun = Utility.FindBody(PSystemManager.Instance.systemPrefab.rootBody, "Sun"); // Clone a default Corona corona = UnityEngine.Object.Instantiate(sun.scaledVersion.GetComponentsInChildren <SunCoronas>(true).First().gameObject) as GameObject; corona.transform.parent = Utility.Deactivator; coronaComponent = corona.GetComponent <SunCoronas> (); // Setup the material loader material = new ParticleAddSmoothLoader(corona.GetComponent <Renderer>().material); material.name = Guid.NewGuid().ToString(); }
public CoronaLoader() { // Is this the parser context? if (!Injector.IsInPrefab) { throw new InvalidOperationException("Must be executed in Injector context."); } // We need to get the body for the Sun (to steal it's corona mesh) PSystemBody sun = Utility.FindBody(Injector.StockSystemPrefab.rootBody, "Sun"); // Clone a default Corona GameObject corona = UnityEngine.Object.Instantiate(sun.scaledVersion.GetComponentsInChildren <SunCoronas>(true).First() .gameObject); // Backup local transform parameters Vector3 localPosition = corona.transform.localPosition; Vector3 localScale = corona.transform.localScale; Quaternion localRotation = corona.transform.rotation; // Parent the new corona corona.transform.parent = generatedBody.scaledVersion.transform; // Restore the local transform settings corona.transform.localPosition = localPosition; corona.transform.localScale = localScale; corona.transform.localRotation = localRotation; Value = corona.GetComponent <SunCoronas>(); // Setup the material loader Material = new ParticleAddSmoothLoader(corona.GetComponent <Renderer>().sharedMaterial) { name = Guid.NewGuid().ToString() }; }
// Default constructor public CoronaLoader() { // We need to get the body for the Sun (to steal it's corona mesh) PSystemBody sun = Utility.FindBody (PSystemManager.Instance.systemPrefab.rootBody, "Sun"); // Clone a default Corona corona = UnityEngine.Object.Instantiate(sun.scaledVersion.GetComponentsInChildren<SunCoronas>(true).First().gameObject) as GameObject; corona.transform.parent = Utility.Deactivator; coronaComponent = corona.GetComponent<SunCoronas> (); // Setup the material loader material = new ParticleAddSmoothLoader (corona.GetComponent<Renderer>().material); material.name = Guid.NewGuid().ToString(); }