18 private TextMesh _frameRateText;
22 private void OnEnable() {
23 if (_provider ==
null) {
24 _provider = Hands.Provider;
27 if (_frameRateText ==
null) {
28 _frameRateText = GetComponentInChildren<TextMesh>();
29 if (_frameRateText ==
null) {
30 Debug.LogError(
"Could not enable FpsLabel because no TextMesh was specified!");
35 _smoothedRenderFps.
delay = 0.3f;
36 _smoothedRenderFps.
reset =
true;
39 private void Update() {
40 _frameRateText.text =
"";
42 if (_provider !=
null) {
47 _frameRateText.text += System.Environment.NewLine;
51 if (Time.smoothDeltaTime > Mathf.Epsilon) {
52 _smoothedRenderFps.
Update(1.0f / Time.smoothDeltaTime, Time.deltaTime);
55 _frameRateText.text +=
"Render FPS:" + Mathf.RoundToInt(_smoothedRenderFps.
value).ToString(
"f2");
The Frame class represents a set of hand and finger tracking data detected in a single frame.
float CurrentFramesPerSecond
The instantaneous framerate.
Provides Frame object data to the Unity application by firing events as soon as Frame data is availab...
abstract Frame CurrentFrame
The current frame for this update cycle, in world space.
Time-step independent exponential smoothing.
float Update(float input, float deltaTime=1f)