예제 #1
0
    void UpdateIngameText()
    {
        // frame rate calculation
        m_SmoothDeltaTime = BuildUtils.SmoothDamp(m_SmoothDeltaTime, Time.unscaledDeltaTime, ref m_DeltaVelocity, 0.7f, Mathf.Infinity, Time.unscaledDeltaTime);
        FPS = m_SmoothDeltaTime > 0.0f ? (1.0f / m_SmoothDeltaTime) : 0.0f;

        if (TextFPS != null && theTextBuilder != null)
        {
            theTextBuilder.Remove(0, theTextBuilder.Length);
            theTextBuilder.Append(Mathf.RoundToInt(FPS));
            TextFPS.text = theTextBuilder.ToString();
        }


        if (TextTimeTotal != null && theTextBuilder != null && theTimelineController != null)
        {
            TimeSpan time = TimeSpan.FromSeconds(theTimelineController.TimerTotal);
            theTextBuilder.Remove(0, theTextBuilder.Length);
            //theTextBuilder.Append(string.Format("{0:hh\\:mm\\:ss\\:f}", time)); // this works well only for time-spans under 24 hours :)
            int hours   = (int)time.TotalHours;
            int minutes = time.Minutes;
            int seconds = time.Seconds;
            theTextBuilder.Append(hours.ToString("D2") + ":" + minutes.ToString("D2") + ":" + seconds.ToString("D2"));
            TextTimeTotal.text = theTextBuilder.ToString();
        }

        if (TextTimePlay != null && theTextBuilder != null && theTimelineController != null)
        {
            theTextBuilder.Remove(0, theTextBuilder.Length);
            theTextBuilder.Append(theTimelineController.TimerPlaystatePlay.ToString("F2"));
            TextTimePlay.text = theTextBuilder.ToString();
        }

        if (TextTimePause != null && theTextBuilder != null && theTimelineController != null)
        {
            theTextBuilder.Remove(0, theTextBuilder.Length);
            theTextBuilder.Append(theTimelineController.TimerPlaystatePause.ToString("F2"));
            TextTimePause.text = theTextBuilder.ToString();
        }

        if (TextTimelineCurrent != null && theTextBuilder != null && theTimelineController != null)
        {
            theTextBuilder.Remove(0, theTextBuilder.Length);
            theTextBuilder.Append(theTimelineController.GetCurrentTimelineName());
            TextTimelineCurrent.text = theTextBuilder.ToString();
        }
    }