• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Add an FPS counter to Unity8 for yourself

Scheduled Pinned Locked Moved Lomiri (was Unity8)
2 Posts 2 Posters 449 Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • U Offline
      UniSuperBox
      last edited by 24 Nov 2019, 21:03

      Just logging something for posterity, maybe someone will find it useful.

      You can add this to the end of Unity8's Shell.qml, but before the final closing brace, to get a (somewhat accurate) FPS counter:

      
          Label {
              id: fpsCounter
              property real t
              property int frame: 0
              color: "red"
              text: "? Hz"
              z: 9999
              textSize: Label.XLarge
      
              anchors {
                  top: parent.top
                  left: parent.left
              }
      
              Timer {
                  id: fpsTimer
                  property real fps: 0
                  repeat: true
                  interval: 1000
                  running: true
                  onTriggered: {
                      parent.text = "FPS: " + fpsTimer.fps + " Hz"
                      fps = fpsCounter.frame
                      fpsCounter.frame = 0
                  }
              }
      
              NumberAnimation on t {
                  id: tAnim
                  from: 0
                  to: 100
                  loops: Animation.Infinite
              }
      
              onTChanged: {
                  update() // force continuous animation
                  ++frame
              }
          }
      

      I'm not interested in making this a "feature" per se, but it's useful for testing if you like.

      Please don't do this on your device, it will get in the way and cause a bunch of CPU and GPU load.

      1 Reply Last reply Reply Quote 2
      • K Online
        kugiigi
        last edited by 25 Nov 2019, 07:13

        I'm interested with the results of each device. So far, in my experience, Nexus 5 is much smoother than bq E5 and MX4. I migh try this one of these days 😄

        1 Reply Last reply Reply Quote 0
        2 out of 2
        • First post
          2/2
          Last post