public static void MarkForDestruction(SgtLightning model) { if (model != null) { model.LightningSpawner = null; model.gameObject.SetActive(true); } }
public static void Pool(SgtLightning model) { if (model != null) { model.LightningSpawner = null; SgtComponentPool <SgtLightning> .Add(model); } }
public SgtLightning Spawn() { if (mesh != null && LifeMin > 0.0f && LifeMax > 0.0f) { var sprite = RandomSprite; if (sprite != null) { var lightning = SgtLightning.Create(this); var material = lightning.Material; var uv = SgtHelper.CalculateSpriteUV(sprite); if (material == null) { material = SgtHelper.CreateTempMaterial("Lightning (Generated)", SgtHelper.ShaderNamePrefix + "Lightning"); lightning.SetMaterial(material); } lightning.Life = Random.Range(LifeMin, LifeMax); lightning.Age = 0.0f; lightning.SetMesh(mesh); material.SetTexture(SgtShader._MainTex, sprite.texture); material.SetColor(SgtShader._Color, SgtHelper.Brighten(RandomColor, Brightness)); material.SetFloat(SgtShader._Age, 0.0f); material.SetVector(SgtShader._Offset, new Vector2(uv.x, uv.y)); material.SetVector(SgtShader._Scale, new Vector2(uv.z - uv.x, uv.w - uv.y)); lightning.transform.localRotation = Random.rotation; return(lightning); } } return(null); }