FPS.Update C# (CSharp) 메소드

Update() 공개 메소드

public Update ( ) : void
리턴 void
	void Update () {
		timeleft -= Time.deltaTime;
		accum += Time.timeScale/Time.deltaTime;
		++frames;
		
		// Interval ended - update GUI text and start new interval
		if( timeleft <= 0.0 )
		{
			// display two fractional digits (f2 format)
			float fps = accum/frames;
			string format = System.String.Format("{0:F2} FPS",fps);
			label.text = format;
			
			if(fps < 10)
				label.color = Color.red;
			else if(fps < 30)
				label.color = Color.yellow;
			else
				label.color = Color.green;

			timeleft = updateInterval;
			accum = 0.0F;
			frames = 0;
		}
	}
}

Usage Example

예제 #1
0
        public override void Update(GameTime gameTime)
        {
            var deltaSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            FPS.Update(deltaSeconds);
            Garbage.Update(deltaSeconds);

            if (_fpsOrGarbageDirty)
            {
                _fpsOrGarbageDirty = false;
                Game.Window.Title  = $"FPS {_fps} | Garbage per sec KB {_garbage.ToString(CultureInfo.InvariantCulture)}";
            }
        }
All Usage Examples Of FPS::Update