static public void SetLightGroup(LightGroup defaultLightGroup)
    {
        var lightGroups = Object.FindObjectsOfType(typeof(LightGroup)) as LightGroup[];
        var lightGroup  = defaultLightGroup;

        if (lightGroup)
        {
            BulletTime.DisableLightGroups(lightGroups);
            BulletTime.SetActiveLightGroup(lightGroup);
        }
    }
    public void Sample(int frame, float frameFraction, int frameCount, WrapMode wrapMode)
    {
        if (BulletTime.paused && !BulletTime.isEditing)
        {
            if (m_ActiveTrigger)
            {
                m_ActiveTrigger.OnCameraExit();
                m_ActiveTrigger = null;
            }
            return;
        }

        if (wrapMode == WrapMode.Loop)
        {
            frame %= frameCount;
        }
        else if (wrapMode == WrapMode.PingPong)
        {
            frame = (int)Mathf.PingPong((float)frame, (float)frameCount);
        }

        var lastTrigger = m_ActiveTrigger;

        m_ActiveTrigger = null;

        int triggerIndex = -1;

        if (wrapMode == WrapMode.Loop && triggers.Length > 0)
        {
            triggerIndex    = triggers.Length - 1;
            m_ActiveTrigger = triggers[triggerIndex];
        }

        for (int q = 0; q < triggers.Length; ++q)
        {
            if (frame >= triggers[q].splineAnimatorFrame || m_ActiveTrigger == null)
            {
                triggerIndex = q;
            }
        }

        int triggerLengthInFrames = 0;

        if (triggerIndex >= 0)
        {
            m_ActiveTrigger = triggers[triggerIndex];
            var nextTriggerIndex = (triggerIndex + 1) % triggers.Length;
            triggerLengthInFrames = triggers[nextTriggerIndex].splineAnimatorFrame - triggers[triggerIndex].splineAnimatorFrame;

            if (triggerLengthInFrames < 0)             // wrap
            {
                triggerLengthInFrames = frameCount + triggerLengthInFrames;
            }
        }


        if (lastTrigger != m_ActiveTrigger)
        {
            if (lastTrigger)
            {
                lastTrigger.OnCameraExit();
            }
            m_ActiveTrigger.OnCameraEnter();

            var lightGroup = m_ActiveTrigger.lightGroup;
            if (!lightGroup)
            {
                lightGroup = defaultLightGroup;
            }
            if (lightGroup)
            {
                BulletTime.SetActiveLightGroup(lightGroup);
            }
        }
        if (m_ActiveTrigger)
        {
            var timeInTrigger = BulletTime.MakeFrameTimeDbl(frame - m_ActiveTrigger.splineAnimatorFrame, BulletTime.frameRate, frameFraction);
            if (timeInTrigger < 0)
            {
                timeInTrigger = BulletTime.MakeFrameTimeDbl(frameCount, BulletTime.frameRate) + timeInTrigger;
            }

            double normalizedTimeInTrigger = 0;
            if (triggerLengthInFrames > 0)
            {
                normalizedTimeInTrigger = timeInTrigger / BulletTime.MakeFrameTimeDbl(triggerLengthInFrames, BulletTime.frameRate);
            }

            m_ActiveTrigger.OnCameraStay((float)timeInTrigger, Mathf.Clamp((float)normalizedTimeInTrigger, 0f, 1f));
        }

        if (BulletTime.isEditing)
        {
            var lightGroup = m_ActiveTrigger.lightGroup;
            if (!lightGroup)
            {
                lightGroup = defaultLightGroup;
            }
            if (lightGroup)
            {
                SetLightGroup(lightGroup);
            }
        }
    }