Search Unity

Advanced FPS Counter [RELEASED]

Discussion in 'Assets and Asset Store' started by codestage, Feb 12, 2014.

  1. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931

    Hello there! I'm glad to share with you my another Asset Store contribution: Advanced FPS Counter!
    It's a simple yet flexible in-game frames per second counter with some additional features.

    Here they are:

    - FPS Counter with optional milliseconds, average, min/max values, render time and customizable coloration intervals
    - Memory Counter (total reserved, allocated, used by Mono and for dev builds - allocated for graphics driver) with optional precise mode
    - Device Info (OS, CPU, GPU, RAM, screen info, model)
    - configurable style and colors for all counters
    - optional background, shadow and outline effects to increase readability on contrast backgrounds
    - flexible counters anchoring (allows to anchor any counter to any screen corner) with stacking in seamless group
    - smart “dirty” update system – counters are updated only when something changes
    - independent update intervals for FPS and Memory counters
    - background operation mode (make benchmarks, collect stats, analyze performance and use you UI easily!)
    - global hotkey to enable / disable plugin with optional modifiers
    - global gesture to enable / disable plugin on any device, even GearVR
    - force FPS option to run your game on specified frame rate (useful e.g. for physics debug)
    - many other features (see inspector screenshot below)



    inspector.png


    Try it in live WebGL demo (best view in latest Chrome and Firefox)!​

    Each feature described in more details in User Manual. Also most of inspector settings have tooltips with additional notes.

    Plugin has tiny footprint and simple setup.
    All settings may be tuned both from inspector and code.
    ExampleScene with common API usage examples included.

    Works fine on all platforms including VR devices.
    Full C# sources included!

    Regular price: $10
    Or get in bundle for a cheaper price!

    Like it? Hate it? Leave a review at the Asset Store to help others to make a good choice.

    Need support, have any questions, suggestions or any other feedback?
    Here are options for you:
     
    Last edited: Sep 8, 2021
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I just purchased this, and after importing, I get a bunch of compiler errors, like this:

    Assets/CodeStage/AdvancedFPSCounter/Examples/APITester.cs(74,65): error CS1061: Type `FPSCounter' does not contain a definition for `ResetAverage' and no extension method `ResetAverage' of type `FPSCounter' could be found (are you missing a using directive or an assembly reference?)
     
  3. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey there, gecko!
    Could you please check if you have any other FPSCounter script in your project?
     
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Hmm, I guess I do -- but that script is tied into some other scripts, so I can't delete it. Is there a way to make the two play well together?
     
  5. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    I see, yeah, you may move my plugin into the Assets\Plugins\ folder to make it compile into the different *firstpass* assembly thus isolating it there.

    I'd be glad to know if it works for you or not.
     
  6. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks. That got rid of the compiler errors, but now when I put Advanced FPS Counter into my scene, I get a new error:

    Instance of AFPSCounterEditor couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.

    EDIT: That error disappears at runtime, but it reappears when I click on the AFPS object in my scene -- and that inspector simply says "Multi-object editing is not supported" even though I only have that one object selected in the hierarchy.
     
    Last edited: Feb 19, 2014
  7. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Ah, this is a bad news - looks like you need to move Plugins\AdvancedFPSCounter\Scripts\Editor folder right to the Assets root thus its path should became Assets\Editor.
    And you need to edit AFPSCounterEditor script itself a bit - remove namespace from it and add line:

    using CodeStage.AdvanecedFPSCounter;

    to the beginning of file.

    I'm really sorry you have to be involved into all this handwork in case you have another script with same name somewhere in project.
    This issue already fixed and will be rolled out with next update.
     
  8. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    That worked, thank you!

    Now I have a problem that's very particular to my project: I have a four-camera setup to create a fisheye effect, and the AFPS readout is being rendered in all four cameras. I would like it to render in another camera that assembles the four-camera views. Is there any way to specify which camera renders the readout?
     
  9. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Actually there is no such option ATM, it will be rendered by all cameras with GUILayer enabled since it renders via GUIText.
    You may try to disable GUILayer component on those four cameras to prevent them from rendering AFPS though.

    EDIT: next update will allow you to select Layer for AFPS.
     
    Last edited: Feb 19, 2014
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Okay, I can disable GUILayer on the four-camera setup, so now it renders in the correct camera. And selecting Layer would be great. One other suggestion: Add a pixel offset for the corner anchors, to allow for more customized placement.

    thanks!
    Dave
     
  11. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Thanks for your suggestion, Dave, added to plugin's TODO!
     
  12. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey everyone!
    I glad to let you new Advanced FPS Counter update is already live in Asset Store!

    Here are new stuff for version 1.1.1:
    - FPSCounter and other counters were renamed to avoid extra name conflicts with other scripts withput namespaces.
    - Layer and Tag of main container are now applied to the labels thus plugin may be easily rendered with desired camera (using culling mask)
    - Added labels pixel offset tuning
    - Added labels line space tuning
    - Added labels font tuning
    - New inspector section - Look and feel, to organize visual tunings

    Hope this tiny update will roll out to your projects smooth!
    Feel free to let me keep aware of any issues you have with plugin.
     
  13. BES

    BES

    Joined:
    Feb 26, 2013
    Posts:
    212
    I bought this asset... it works great..thanks!

    Any way to add draw calls and other details like the "stats" from Unity Editor's play mode to Advanced FPS Counter?

    I know people probably think those details are useless.. but not if I publish a "developer" version of my project to see how things run on other computers..

    Need it to work for both Unity free and Pro.
     
    Last edited: Apr 7, 2014
  14. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, BES!
    Glad it works for you!
    I'm afraid it is pretty hard if possible to count real draw calls amount from code. I'll investigate it further, but I'd suggest to not await for this feature in near future.
     
  15. BES

    BES

    Joined:
    Feb 26, 2013
    Posts:
    212
    Ok, thanks for the quick response, Advanced FPS Counter will still be very useful for "dev" builds even without the draw calls stuff, just figured I would ask.
     
  16. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    The mono stats, can it be used for memory allocation tracking?
     
  17. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Could you please tell me more about mono stats? I'm afraid I don't know about them yet (never heard anything about mono stats before).
     
  18. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    The Mem Mono in your screenshot, what does that measure?
     
  19. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Ah, I see now what are you asking about. It shows amount of memory, allocated for not collected mono (managed) objects.
    In Flash Player it shows total memory usage by Flash Player plugin process.
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Cool plugin! How difficult is it to modify this to work with NGUI label or DF-GUI text? I think on mobile, this will actually show a much worse FPS than is real just because it is using a GUIText (I assume it is using that), because mobile devices perform terribly with GUI Text...

    Maybe you should include optional packages in the plugin for users that have those plugins?
     
  21. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, Brian!
    First of all, thanks for noticing my plugin =D

    I did tested it on mobiles and I should say it is not so terrible there. Yep, it relies on GUIText, but it's not so bad as OnGUI labels at least, you know =)

    All data plugin provides is usually used for testing and debug purposes, plugin doesn't use any resources while it's turned off. And it have maximum 4 GUITexts on the screen with as rare content updates as possible. So it's easy to avoid extra resources waste - just disable it while you don't need it.

    After all, I'm not sure investing into the popular third-party GUI support worth it at all =\ Let me explain this.
    I try to keep plugin as simple and as cheaper as possible, and I'm afraid support of different third-party GUI solutions may be not compatible with those points I try to keep in mind while working on it.
    And I'm not sure what will happen with third-party GUI solutions after uGUI release.
     
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok, GUIText not as bad as OnGUI, didn't know that. I gave up on Unity GUI after OnGUI. Killed performance entirely :)

    About third-party GUI solutions after uGUI release, I'm pretty sure they will still be very popular for at least 6 months or a year after uGUI comes out. You see, most people don't believe uGUI will be as fully featured as these mature products when it's initially released. I hope it is, but that's not what Unity's track record shows (Mechanim / 2D).

    Anyway, I'll probably your plugin, and if I make an NGUI version or DF-GUI version, I'll post it here in the thread or email it to you for possible inclusion in a future version. It should be very simple.
     
  23. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Sure, thanks!
     
  24. teslatron

    teslatron

    Joined:
    Sep 20, 2013
    Posts:
    8
    Hi,
    I've bought FPS counter and it does its job well, good job.

    But with the memory information I saw that if profiler not enabled you use System.GC.TotalMemory() which seems not very helpful. I found Profiler.GetTotalReservedMemory() still works whether profiler is enabled or not. Profiler.GetTotalReservedMemory() is almost equal to what Task Manager says. So its private memory of the process, thats what matters if you are making a windows app ;)

    But I didn't test what happens if it is mobile, flash or browser.
     
  25. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I looked at profiler, it is generating small amount of garbage every frame in WaitForKeyDown
     
  26. arjeriababa

    arjeriababa

    Joined:
    Jan 26, 2014
    Posts:
    22
    What are the things i need to do to run it on my android?? Please Reply.... I will definitely buy it.
     
  27. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Oh, damn notifications! Absence of them actually =\

    @teslatron
    Thanks for your comment, I'll definitely check Profiler.GetTotalReservedMemory out! Looks like it's still not documented though.

    @imtrobin
    This is a coroutine-driven method thus it generates some garbage. I did tested continuous coroutine vs Update recently and Update is faster and memory-wiser choice. Thus I'll consider getting rid of continuous coroutines in next update. Thanks for your comment.

    @arjeriababa
    Nothing special. It should work same on all platforms without any efforts from your side.
     
  28. Robota

    Robota

    Joined:
    Feb 7, 2012
    Posts:
    82
    Hi Dmitriy, I have just purchase your plugin.

    I works great on the editor, see the screenshot below.
    Screen Shot 2014-07-03 at 12.19.48.png

    But on the web player, the mono mem always display 0 and the heap mem is not displayed.
    Screen Shot 2014-07-03 at 12.19.24.png
    Can you help me on this?
    Thx.
     
  29. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, Robota!
    It's an expected behaviour I guess. I suppose you have less then 1 MB of Mono allocations, you may try to enable precise flag to see 0.xx values.

    And you have no heap counter because there is no profiler available in WebPlayer build. Please, note it will change in future update, I'm going to provide additional total memory usage counter.
     
  30. Robota

    Robota

    Joined:
    Feb 7, 2012
    Posts:
    82
    Ok, it makes sense!
    Thank you for your quick reply ;)
     
  31. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @imtrobin
    I did a small research on WaitForKeyDown GC allocations. Here are results and some additional comments from my side:
    • these allocations are somewhat expected since WaitForKeyDown runs in the Coroutine which generates this allocations (9 bytes each frame in my case)
    • I don't see any GC spikes because of this allocations, looks like this garbage is cleaned up effectively
    • I use coroutine for this in order to keep key listener running even if whole component is disabled and to keep setup as clean as possible, packing all things into one component
    • My other options are: InvokeRepeating or Update
    • InvokeRepeating can't be run in sync with frame rate to guarantee once per frame shot, otherwise it needs some additional care to workaround multiple shots per frame
    • Update wouldn't work if component is completely disabled (which is an expected behaviour when it get disabled with hotkey or from code for now)
    • I'm going to implement custom operation levels instead of enable / disable in future versions. Example: Normal, RunInBackground (to let read counter values without showing them to the end user, may be helpful for performance stats), Disabled. I'll re-implement key listener and try to get rid of this coroutine and extra allocations on that update. Not sure how soon it will be implemented though.
    Please, let me know if those allocations are making some troubles in your project and I'll try to help with some custom quickfix for you until new version with operation levels come out.
     
  32. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey guys! I'm glad to report about new 1.2.0.2 version release!
    Most important - plugin doesn't require Unity Pro for additional memory readouts anymore. And now it shows all memory counters in Web Player.


    Here is a full change log:

    1.2.0.2
    - fixed typo in the namespace (thanks Daniele Giardini)

    1.2.0.1
    - removed UnityEditor import from AFPSCounter.cs

    1.2.0
    - Total reserved memory readout added to the Memory Counter
    - Allocated memory readout added to the Memory Counter
    - Heap Usage removed from Memory Counter (it required enabled Profiler)
    * plugin’s features aren’t affected by Profiler existance anymore
    - added additional checks for correct camera set up including its culling mask (while running in Editor)
    * now AFPSCounter should warn in all incorrect camera settings cases, please report if you don’t see
    counter and have no any warnings in your console at the same time
    - optimal AFPSCounter settings are now saved as prefab
    - minor fixes and optimizations
    - improved API docs look and feel
    - minor additions and changes in API docs

    Already available at Asset Store!
     
    Last edited: Jul 9, 2014
  33. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Hi, I see you have not yet use Update. Generating garbage every frame is bad for mobile.
     
  34. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, imtrobin!
    You already reported extra garbage issue, no worries, it's on top of my TODO list and will be fixed automatically with new background mode introduction (WIP).
     
  35. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey guys!
    Here is a short 2-screenshots WIP status:
    https://twitter.com/dmitriy_focus/status/491002380771921920

    From changelog:
    - Added AverageFromSamples property for FPSCounter, read more in API docs
    - Operation Modes introduced! Read more in API docs and readme.pdf, short quotes from docs:
    * Disabled: removes labels and stops all internal processes except Hot Key listener
    * Background: removes labels keeping counters alive, may be useful for performance monitoring and benchmarking
    * Normal: shows labels and runs all internal processes as usual

    A little bit more information about upcoming AverageFromSamples property.
    Currently average FPS calculated from all readout samples since game / level start (or after manual reset with ResetAverage() API). One readout occurs per configured by user update interval.
    New property allows to optionally set range of last readout samples to calculate average from. E.g. if user set it to 10, average value will be calculated from last 10 FPS readouts instead of all readouts since start / reset.
    If you still wish to calculate average FPS from all readouts, just set Samples to 0 and internal mechanics will automatically switch back to the old logic.

    And few words about new Operation Modes.
    I'd like to add few details about Background mode (since Disabled and Normal behaves as former enabled field).
    So, Background mode hides all counters and stops most of visualization logic.
    It allows:
    1) collect performance / device hardware statistics.
    2) suggest better visual settings for robust user experience (you may see how much RAM budget you have and how much FPS user has with current settings for example).
    3) Implement own ways to present counters data. This probably will be used by myself in further updates (I'm thinking on adding support for few third-party GUI engines and upcoming uGUI).

    @imtrobin BTW, your request successfully processed - no more WaitForKeyDown coroutine!

    ERD: this week end (may shift to the next week though)!

    Have a great time!
     
  36. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Update: new version release may easily shift to next week end or even a bit further since I'm going to include into this update some more cool things and I'm thinking about price increase from $5 up to $10 (not decided yet).

    Poll: are you think plugin worth $10 (counting announced features in previous post)?
     
  37. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Woot, 1.2.5 already at the Asset Store!
    See what this update brings:

    1.2.5 [Clean update suggested!]
    - Added AverageFromSamples property for FPSCounter, read more in API docs
    - Operation Modes introduced! Read more in API docs and readme.pdf, short quotes from docs:
    * Disabled: removes labels and stops all internal processes except Hot Key listener
    * Background: removes labels keeping counters alive, may be useful for performance monitoring and benchmarking
    * Normal: shows labels and runs all internal processes as usual
    - MinMax FPS option: allows to see Minimum and Maximum FPS since game or scene start (depending on ResetOnLoad flag)
    - Hot Key listener is now Update-based instead of Coroutine-based to nail down extra allocations
    - fixed numerous bugs with how keepAlive mode works in both enabled and disabled state
    - Flash Player support dropped, some ugly code cleaned up
    - namespace CodeStage.AdvancedFPSCounter.Label was renamed to the CodeStage.AdvancedFPSCounter.Labels
    - AFPSCounter inspector layout changed a bit
    - AFPSCounter component placement strictness was reduced (now you may rename Game Object with AFPSCounter)
    - readme.pdf remastered from scratch (more detailed descriptions now)
    - some default values in example prefab were tuned
    - removed auto-hide of the Force FPS slider to let you tune desired FPS before enabling it
    - changes in demo scene to reflect new features
    - major refactorings, preparation for the custom counters (stay tuned! :p)
    - minor optimizations
    - docs cleanup, fixes and additions
    - price is raised a bit

    As you could notice (if you read up to the end), plugin price raised a bit, now it's a $10 for this piece of software. I decided it would be fair to increase price a bit since plugin significantly changed since its first release in Feb 2014 =)
     
  38. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Hi Dmitriy,

    Thanks for this great asset.

    Is there anyway to auto scale the font size at run-time based on screen resolution?
     
  39. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @schmosef!
    Sure, just use AFPSCounter.Instance.FontSize property to change font size at runtime.
     
  40. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    25
    hi,
    what's up with this warning?

    if (len == 0 || Math.Abs(highestCameraDeph - highestSuitableCameraDeph) > 0.0001f)
    {
    Debug.LogWarning("Please check you have camera and your top-most (highest depth) camera\nhas enabled GUILayer and has layer " + LayerMask.LayerToName(gameObject.layer) + " in the camera's culling mask!");
    }

    ?
     
  41. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, it warns you about your top-most camera doesn't have FPS Counter's layer checked in the culling mask.
    Thus, FPS Counter may be not visible in scene.
    Feel free to remove it if you're using not the top-most camera to render AFPSCounter or not rendering it at all (in case of background operation mode).
    This warning logics will be revisited in the next plugin update.
     
  42. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    I get the same warning when i try to use this together with the UFPS asset from the Unity store.
    There are three cameras and at none of them is the FPS Counters layer in the culling mask so i can not check it.
    Can you help?
     
  43. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @RandAlThor!
    Please make sure you have added layer of the AFPSCounter component game object to the culling mask of desired camera and you have GUILayer enabled on that camera too.

    And feel free to drop me an email with repeatable case if you still have this issue to let me check it out.
     
  44. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    New 1.2.6 version released!

    Changelog:
    - added "Move all to" editor-only functionality to move all counters to the specified anchor label
    - added new "Counters spacing" slider to control lines amount between different counters in single label
    - added new "On new line" option for MinMax FPS to let you place all FPS data on a single line
    - fixed NullReferenceException if MinMax FPS's "Reset now" was pressed not in the Play Mode
    - important changes in API: new static AddToScene(), Dispose() became static as well and Instance can be null now
    - placement strictness softened - third-party scripts are allowed on AFPSCounter's Game Object now
    - editor check for camera settings revisited - ignores depth now, should be more accurate
    - added few editor checks for correct placement
    - minor improvements of the inspector layout
    - Unity 5.0 fully supported (tested on Unity 5.0 beta 17)
    - project updated to Unity 4.5.5
    - few fixes and additions in the docs
    - minor optimizations
    - minor fixes
     
    gurayg likes this.
  45. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Can you add MS delay for FPS please ?

    Would be very appreciate :)
     
  46. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Sure, added this to the top of my todo, hope to release with next update.
    Thanks for your request!
     
  47. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    354
    It doesn't show anything when there is a canvas and image etc (Unity 4.6 UI ) on the screen that fulfills the screen. Why?
     
  48. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @hakankaraduman!

    This is because uGUI draws on top of the GUIText layer by default (if you have Screen Space - Overlay render mode selected for your Canvas).
    To let AFPSCounter draw on top of uGUI, just make this simple steps:
    1. Set Canvas render mode to the Screen Space - Camera: http://i.imgur.com/SpH9VtB.png
    2. Assign Canvas Render Camera property with the camera which renders AFPSCounter: http://i.imgur.com/dvcEZiJ.png
     
  49. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    354
    Thanks for the quick answer
     
  50. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Would be good you fix uGUI conflict in the next release by default :)