示例#1
0
        void Update()
        {
            if (this.changeButtonTextWhileConnecting)
            {
                if (m_text)
                {
                    string newText = "";

                    if (NetworkStatus.IsClientConnecting())
                    {
                        // if client is connecting, change text

                        m_stringBuilder.Length = 0;
                        m_stringBuilder.Append(this.prefixText);
                        int numDots = ((int)Time.realtimeSinceStartup) % 4;
                        for (int i = 0; i < numDots; i++)
                        {
                            m_stringBuilder.Append(".");
                        }

                        newText = m_stringBuilder.ToString();
                    }
                    else
                    {
                        // restore original text
                        newText = m_originalButtonText;
                    }

                    if (newText != m_text.text)
                    {
                        m_text.text = newText;
                    }
                }
            }

            if (this.disableButtonWhileClientIsActive)
            {
                // if client is active, disable button
                if (m_button)
                {
                    m_button.interactable = !NetworkStatus.IsClientActive();
                }
            }
        }
示例#2
0
        void Update()
        {
            // calculate average fps
            float timeElapsed = this.fpsStopwatch.ElapsedMilliseconds / 1000f;

            if (0f == timeElapsed)
            {
                timeElapsed = float.PositiveInfinity;
            }
            this.fpsStopwatch.Reset();
            this.fpsStopwatch.Start();

            float fpsNow = 1.0f / timeElapsed;

            fpsSum += fpsNow;
            fpsSumCount++;

            if (Time.time - lastTimeFpsUpdated > secondsToUpdateFps)
            {
                // Update average fps
                if (fpsSumCount > 0)
                {
                    averageFps = fpsSum / fpsSumCount;
                }
                else
                {
                    averageFps = 0;
                }

                fpsSum      = 0;
                fpsSumCount = 0;

                lastTimeFpsUpdated = Time.time;
            }


            if (NetworkStatus.IsClientConnecting())
            {
                this.timePassedSinceStartedConnectingToServer += Time.deltaTime;
            }
        }