Пример #1
0
        void Update()
        {
            // The Demo song has a quarter note as it's beat value.  This will get us the current
            //  quarter note!
            int curQuarterNote = Mathf.FloorToInt(Koreographer.GetBeatTime());

            if (curQuarterNote != lastQuarterNote)
            {
                // Turn the group on when the beat is an even number.
                SwitchGroup(quarterNoteGroup, lastQuarterNote % 2 != 0);

                lastQuarterNote = curQuarterNote;
            }

            // The 'null' value asks Koreographer to look at the beat time of what it considers
            //  the current "Main" song.  These demos use a basic player with a single song and
            //  define that as the Main song.  Therefore there is no need to specify it.  The
            //  '2' parameter, tells Koreographer to divide each beat into 2 equal parts.  As the
            //  base beat value is 4, this will result in eighth notes.
            int curEighthNote = Mathf.FloorToInt(Koreographer.GetBeatTime(null, 2));

            if (curEighthNote != lastEighthNote)
            {
                SwitchGroup(eighthNoteGroup, lastEighthNote % 2 != 0);

                lastEighthNote = curEighthNote;
            }
        }
Пример #2
0
    private int iLastEighthNote  = 0;   // 上一个八分音符

    private void Update()
    {
        /// 四分音符
        int iCurQuarterNote = Mathf.RoundToInt(Koreographer.GetBeatTime());

        // 当前的四分音符 != 上一个四分音符
        if (iCurQuarterNote != iLastQuarterNote)
        {
            // 开关灯
            SwitchGroup(m_QuarterNoteGroup, iLastQuarterNote % 2 != 0);
            // 记录此时的四分音符
            iLastQuarterNote = iCurQuarterNote;
        }

        /// 八分音符
        int iCurEighthNote = Mathf.RoundToInt(Koreographer.GetBeatTime(null, 2));

        // 当前的八分音符 != 上一个八分音符
        if (iCurEighthNote != iLastEighthNote)
        {
            // 开关灯
            SwitchGroup(m_EighthNoteGroup, iLastEighthNote % 2 != 0);
            // 记录此时的八分音符
            iLastEighthNote = iCurEighthNote;
        }
    }