private void UpdateRenderer()
 {
     if (lightningBoltRenderer == null)
     {
         lightningBoltRenderer = new LightningBoltMeshRenderer();
     }
     lightningBoltRenderer.MaterialNoGlow = lightningMaterialMeshNoGlowInternal;
     lightningBoltRenderer.Script = this;
     lightningBoltRenderer.Material = lightningMaterialMeshInternal;
 }
        public void Initialize(Camera camera, bool useWorldSpace, LightningBoltMeshRenderer lightningBoltRenderer,
            GameObject parent, LightningBoltScript script, ParticleSystem originParticleSystem,
            ParticleSystem destParticleSystem, ICollection<LightningBoltParameters> parameters)
        {

#if DEBUG

            // setup properties
            if (parameters == null || lightningBoltRenderer == null || parameters.Count == 0 || script == null)
            {
                Debug.LogError("Parameters, renderer and script must be non-null");
                return;
            }

#endif

            this.Camera = camera;
            this.UseWorldSpace = useWorldSpace;
            this.SortLayerName = script.SortLayerName;
            this.SortOrderInLayer = script.SortOrderInLayer;
            this.lightningBoltRenderer = lightningBoltRenderer;
            this.Parent = parent;
            this.Script = script;

            CheckForGlow(parameters);
            lightningBoltRenderer.Begin(this);
            MinimumDelay = float.MaxValue;
            int maxLightsForEachParameters = MaximumLightsPerBatch / parameters.Count;
            foreach (LightningBoltParameters p in parameters)
            {
                ProcessParameters(p, originParticleSystem, destParticleSystem, maxLightsForEachParameters);
            }
            lightningBoltRenderer.End(this);
        }
 public void Cleanup()
 {
     foreach (LightningBoltSegmentGroup g in segmentGroups)
     {
         foreach (Light l in g.Lights)
         {
             CleanupLight(l);
         }
         g.LightParameters = null;
         g.Segments.Clear();
         g.Lights.Clear();
         g.StartIndex = 0;
         LightningGenerator.groupCache.Add(g);
     }
     CleanupLight(lightOnlyObject);
     lightOnlyObject = null;
     lightOnlyParameters = null;
     segmentGroups.Clear();
     segmentGroupsWithLight.Clear();
     if (lightningBoltRenderer != null)
     {
         lightningBoltRenderer.Cleanup(this);
         lightningBoltRenderer = null;
     }
     hasLight = false;
     elapsedTime = 0.0f;
     lifeTime = 0.0f;
     lightningBoltCache.Add(this);
 }