Navigation

    UBports Robot Logo

    UBports Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Add an FPS counter to Unity8 for yourself

    Lomiri (was Unity8)
    2
    2
    140
    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
      UniSuperBox last edited by

      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
        kugiigi last edited by

        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
        • First post
          Last post