public Atmosphere(GameObject spaceCraft, OrbitalSystem rootObject, string name, int idx, float dist, float spin, float offset, Vector3 hdg, bool enterable, Texture2D txtr = null, AtmosphereTriggerScript.AtmosphereEntryHandler entryHandler = null) { SpinSum = 0; Name = name; Index = idx; Distance = dist; Spin = spin; SpinOffset = offset; Texture = txtr; Distance = dist; Shape = GameObject.CreatePrimitive(PrimitiveType.Sphere); Shape.name = name; SphereCollider sc = Shape.GetComponent<SphereCollider>(); //sc.radius = 1; float baseSize = rootObject.SimulationRadius; baseSize += Distance; Shape.transform.parent = rootObject.Root.transform; Shape.transform.position = rootObject.Root.transform.position; Shape.transform.rotation = rootObject.Root.transform.rotation; if (!enterable) { Rigidbody rb = Shape.AddComponent<Rigidbody>(); rb.drag = 0.0f; rb.mass = 0; rb.angularDrag = 0; rb.useGravity = false; rb.isKinematic = true; } if (enterable) { sc.isTrigger = true; AtmosphereTriggerScript ts = Shape.AddComponent<AtmosphereTriggerScript>(); ts.SpaceCraft = spaceCraft; ts.EntryHandler = entryHandler; } if (Texture == null) { Shape.GetComponent<MeshRenderer>().enabled = false; } else { MeshRenderer mr = Shape.GetComponent<MeshRenderer>(); mr.enabled = true; //mr.material.SetOverrideTag("RenderType", "Transparent"); mr.material.SetFloat("_Mode", 2); mr.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); mr.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); mr.material.SetInt("_ZWrite", 0); mr.material.DisableKeyword("_ALPHATEST_ON"); mr.material.DisableKeyword("_ALPHABLEND_ON"); mr.material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); mr.material.renderQueue = 3000; mr.material.mainTexture = Texture; } Shape.transform.localScale = new Vector3(baseSize, baseSize, baseSize); // m_shape->SetOrderHint(idx + 1); BaseHeading = hdg; }
public int AddAtmosphere(GameObject spaceCraft, float surfDist, float spin, float spinOffset, bool enterable, Texture2D ts = null, AtmosphereTriggerScript.AtmosphereEntryHandler entryHandler = null) { var atmosphere = new Atmosphere(spaceCraft, this, GetName() + "Atmosphere" + mAtmospheres.Count, mAtmospheres.Count, surfDist, spin, spinOffset, Vector3.zero, enterable, ts, entryHandler); mAtmospheres.Add(atmosphere); //SortAtmospheres(); return mAtmospheres.Count - 1; }