예제 #1
0
 private void EnableCurrentLineRenderer()
 {
     if (activeLineRenderers.Count == 0)
     {
         return;
     }
     // make sure the last renderer gets enabled at the appropriate time
     else if (MinimumDelay <= 0.0f)
     {
         EnableLineRenderer(activeLineRenderers[activeLineRenderers.Count - 1], activeLineRenderers[activeLineRenderers.Count - 1].Tag);
     }
     else
     {
         dependencies.StartCoroutine(EnableLastRendererCoRoutine());
     }
 }
예제 #2
0
        private void ProcessAllLightningParameters()
        {
            int           maxLightsForEachParameters = MaximumLightsPerBatch / dependencies.Parameters.Count;
            RangeOfFloats delay        = new RangeOfFloats();
            List <int>    groupIndexes = new List <int>(dependencies.Parameters.Count + 1);
            int           i            = 0;

#if ENABLE_PROFILING
            System.Diagnostics.Stopwatch w = System.Diagnostics.Stopwatch.StartNew();
#endif

            foreach (LightningBoltParameters parameters in dependencies.Parameters)
            {
                delay.Minimum        = parameters.DelayRange.Minimum + parameters.Delay;
                delay.Maximum        = parameters.DelayRange.Maximum + parameters.Delay;
                parameters.maxLights = maxLightsForEachParameters;
                groupIndexes.Add(segmentGroups.Count);
                ProcessParameters(parameters, delay, dependencies);
            }
            groupIndexes.Add(segmentGroups.Count);

#if ENABLE_PROFILING
            w.Stop();
            UnityEngine.Debug.LogFormat("GENERATE: {0}", w.Elapsed.TotalMilliseconds);
            w.Reset();
            w.Start();
#endif

            LightningBoltDependencies dependenciesRef = dependencies;
            foreach (LightningBoltParameters parameters in dependenciesRef.Parameters)
            {
                Transform transform = RenderLightningBolt(parameters.quality, parameters.Generations, groupIndexes[i], groupIndexes[++i], parameters);

#if !UNITY_WEBGL
                if (dependenciesRef.ThreadState != null)
                {
                    dependenciesRef.ThreadState.AddActionForMainThread(() =>
                    {
                        dependenciesRef.StartCoroutine(NotifyBolt(dependenciesRef, parameters, transform, parameters.Start, parameters.End));
                    });
                }
                else
#endif

                {
                    dependenciesRef.StartCoroutine(NotifyBolt(dependenciesRef, parameters, transform, parameters.Start, parameters.End));
                }
            }

#if ENABLE_PROFILING
            w.Stop();
            UnityEngine.Debug.LogFormat("RENDER: {0}", w.Elapsed.TotalMilliseconds);
#endif

#if !UNITY_WEBGL
            if (dependencies.ThreadState != null)
            {
                dependencies.ThreadState.AddActionForMainThread(EnableCurrentLineRendererFromThread);
            }
            else
#endif

            {
                EnableCurrentLineRenderer();
                dependencies.AddActiveBolt(this);
            }
        }