I am trying to create a FPS counter for android, but i don’t know how to create a small counter to run in the top corner even when the app is closed.
I need no help with the script to calculate the fps.
Thank you
Just make a canvas and put a UI text element in the top left corner. Update it each frame with the current frame rate.
Not sure what you mean by doing it while the app is closed though. I’m not sure framerate really has meaning when you’re not displaying anything on screen.
Is that even possible? I don’t develop for Android, so maybe there’s some cool android-only API for displaying content even when an app isn’t open/focused? To me, that sounds like the kind of behavior that would be heavily abused by apps, and would be disallowed. Are you sure this kind of thing is even possible at the OS level?
You won’t be doing this via any mechanism contained in Unity. You’ll need to write a custom Android activity and bless it with background privileges, and it has a whole bunch of implications and OS-specific warts and whistles:
https://stackoverflow.com/questions/15472383/how-can-i-run-code-on-a-background-thread-on-android
Once you get the basic activity functional I imagine you might be able to get it into an AAR and start it under Unity, but I certainly haven’t attempted such a brave thing myself.
Good luck!