Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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
    Oh. This is even more weird!

    AFPSCounter doesn't switches scenes, so it has nothing to do with new SceneManager APIs.
    Maybe you're using some specific settings for the Android build I don't know about?
    I still was unable to reproduce it on my side =(
    It would be awesome to have a project with reproducible issue.
     
  2. maltakereuz

    maltakereuz

    Joined:
    Mar 29, 2015
    Posts:
    53

    Just bought it. Looks wonderfull, but... how this can be true? AFPSCounter says FPS is 172 and Unity-FPS-Stat says its over 600.... Who lies? Is it vsync related?
     
  3. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @maltakereuz !
    Thanks for your purchase, I've answered similar question before let me quote it once more:

    Need to put it to the readme, I totally understand the confusion, will add it there on the next update.

    BTW, maybe white colors for counters will save your eyes until I release an update with shadows \ backgrounds.
     
  4. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Dmitriy Yukhanov Hi Dmitriy, I have a request: would it please be possible for the FPS font to have a black outline? I'm asking because any solid color, depending on the underlying picture is going to be unreadable at one point or another. And having a black outline around the text/numbers would make it readable in ALL the color-on-color situations. Thanks!
     
    codestage likes this.
  5. codestage

    codestage

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

    Thanks for your feedback.

    Yep, next update will bring such features as font shadow \ outline and \ or colored background for all counters, stay tuned!
     
  6. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    That's great! Thank you very much, Dmitriy! :)
     
    codestage likes this.
  7. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Dmitriy Yukhanov Hi there, I just stumbled upon an issue with the new counter which I hope is going to be simple to fix: with the previous version it was possible to toggle the AFPS game object by using .SetActive(true/false). But now that doesn't seem to work anymore (the game object refuses to stay deactivated in the inspector).

    So my question is simple: how can I turn on/off the counter via code in an editor script? Thanks...
     
  8. codestage

    codestage

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

    This is strange, it should work as usual.
    Could you please provide more data?
    - how you're trying to deactivate it?
    - does manual deactivation (uncheck the activation checkbox by mouse) works for you?
    - what's your Unity version?

    Thanks!
     
  9. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Sure, here's the info: I'm on Windows 8.1 and Unity 5.3.1p3.

    - I'm trying to deactivate the game object via code by using fpsGO.SetActive(false); But as I said it doesn't work (the object is NOT deactivated).
    - Manual deactivation does not work. When clicking on the checkbox at the top of the inspector nothing happens; the checkbox remains checked.
     
  10. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hm. Just tried to reproduce it on 5.3.1f1 and it looks fine, I can deactivate AFPSCounter object both from code and from inspector.

    Does it reproduces for you in the new project, in the example scene?
    Is it possible to get the repro case within the .unitypackage?
     
  11. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Then sounds like it could be an error in my code. Let me take another look... :confused:
     
  12. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, please let me know if you managed to figure out the cause of the issue. I'd be glad to help if you still having this trouble.
     
  13. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Dmitriy Yukhanov Hey Dmitriy, I'm sorry but a cascade of issues started pouring down yesterday and I'm only now managing to get my head above the water. Good news, it was all a silly mistake in my code!

    Thank you for your reactivity and my most sincere apologies for the false alarm! :oops:
     
  14. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Ah, good to hear everything is fine now, thanks for letting me know!
     
  15. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Dmitriy Yukhanov Hi there, it looks like I may have stumbled on an issue: since I updated to 5.3.2f2 it seems the AFPS doesn't show up in builds anymore. I mean in the editor it's there but in a build its nowhere to be seen (as if it were deactivated).

    Does anyone have the same issue? Or am I doing something wrong?
     
  16. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey @Seith

    It should work fine in 5.3 and any version since 4.6.1 in general.

    What is your target platform?
    And does example scene works on your target device and you can see counter there?
     
  17. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    The target platform is standalone (Windows). And I just did a build of the example scene and it's the same; the fps is not displayed on-screen.

    Edit:
    Here's the inspector for the prefab in the example scene:
     
  18. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Thanks for detailed answer!

    Does it reproduces with example scene in new project? Maybe some project settings affect it...
    Just tested on PC in 5.3.2f1 and 5.4 beta 6 - works as expected in both cases.
     
  19. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Ok it took a moment but I have it working again; I had to delete the folder, re-download and re-import the asset. Must have gotten corrupted during an upgrade.

    Thanks! Oh and by the way, any ETA on the outline/shadow on the font? :)
     
  20. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Thanks for the update, hope it was some glitch from Unity side, will keep an eye on such issue.

    Visibility improvement is coming with next update, as soon as I reach it, hope to get it live at first half of March, but not guaranteed.
     
    Seith likes this.
  21. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Alright, I have more information about this issue. Here's what's happening: we start in a loading scene (without the AFPS prefab) and we then load the main scene (which contains the AFPS). And that seems to be the problem. By the way it happens both in-editor and in-build.

    When the second scene is loaded (not additively, it replaces the first scene) the AFPS prefab is nowhere to be seen; it's like it's been destroyed. It should be there, but it is not.

    I repeat: scene A does NOT have the AFPS prefab. But when scene B is loaded (which contains the AFPS prefab) the AFPS prefab has disappeared from the scene. I was able to bypass the issue by checking "Keep Alive", but there are to minor problems with that:

    1) The way I understand it, the Keep Alive option should simply avoid destroying the prefab if it was already loaded in scene A in order to keep it for scene B. But as I explained, scene A does NOT have the prefab. So I don't understand the logic. And I certainly don't understand why the AFPS prefab would be automatically destroyed in scene B.

    2) The AFPS prefab in scene B is not at the root level of the hierarchy (it can't be) and so it complains by saying "[AFPSCounter]: Keep Alive option will not work at the non-root Game Object!". This seems to suggest the Keep Alive option won't behave properly in such a case. And yet, it looks like the Keep Alive toggle has some effect after all. So I'm a bit confused I guess.

    Anyway, I hope this will help you pinpoint the issue...
     
    codestage likes this.
  22. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Huge thanks for your detailed comments, it will help for sure I'll try to reproduce it and fix the issue as soon as possible.
     
    Seith likes this.
  23. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @Seith

    I confirm it as a bug on my side, thanks for your feedback once again!
    Fix will be available with next update.
    Currently keepAlive logic is broken in some cases like yours, all because we have no control over the DontDestroyOnLoad (we can't disable it once enabled, and we can't figure out if it's enabled on some object).

    Thus I'll significantly change the way keepAlive works, it will be more predictable but with one limitation - on / off flag will apply only once, on Start of the AFPSCounter.

    Please let me know if you need an urgent solution and you can't wait for the update and I'll provide you dev version with fix.
     
  24. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Ah I understand, thanks Dmitriy! That sounds good. It's ok, I don't need an urgent fix as using the Keep Alive option seems to work (despite the iffy logic and the warning related to the non-root hierarchy). So I'll wait for your next official update! Would you mind doing a post here when it does go live, please? Cheers!
     
  25. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Sure, I'll post here as update will be available, thanks and back-cheers! =D
     
  26. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    139
    After the API bit can you add a string (SystemInfo.graphicsDeviceType) on the end so I can see the API currently being used? Maybe do a formatted version to keep it short?

    I replaced line 200 in DeviceInfoCounterData.cs with:

    .Append(", API: ").Append(SystemInfo.graphicsDeviceVersion + " (" + SystemInfo.graphicsDeviceType + ")");
     
    Last edited: Mar 1, 2016
  27. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @GenOli

    Sure thing, will add it in future update.

    Thanks for your FR!
     
    GenOli likes this.
  28. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    New version dev update!

    Current release version:



    Current dev version:



    - optional shadow & outline effects, with customizable colors and distance
    - new Platform section in the device info counter (OS)
    - graphics API type in Unity 5.3.2+ at the device info counter (cc: @GenOli)
    - lots of other improvements etc.
    - it's not all yet for this update, development continues!

    Stay tuned!
     
    John-G, Tinjaw and GenOli like this.
  29. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Excellent! Looking forward to it!
     
  30. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    Shadows and outline really make it stand out, thanks for implementing.
     
  31. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Thanks, BTW new version already sent for review!
     
    John-G likes this.
  32. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Glad to let you guys know new version is live at the store now!

    Main highlights:
    - shadow and outline effects
    - new OS info in the DeviceInfo counter
    - important bugfixes and improvements

    You also may check the updated WebGL demo:
    http://codestage.ru/unity/fpscounter/demo/

    1.3.1.0
    - added Shadow and Outline effects
    - added new Platform section to the DeviceInfo output
    * shows OS name and version
    * shows runtime platform​
    - added optional output in MS for Average and MinMax FPS
    - added optional hotkey modifiers: Ctrl \ Cmd, Alt and Shift
    - added graphicsDeviceType output in DeviceInfo (for Unity 5.3.2 and higher)
    - changed keepAlive logic, now it applies on Start phase and works as expected
    * pass it to the AddToScene() to use it from code
    * applies to the root Game Object, allowing to use it on the nested one​
    - added explicit System.* usage in some cases to avoid collisions with user code
    - added support for the Unity 5.4's SceneManager.sceneLoaded delegate
    - added option to move Average FPS on the new line
    - divided GPU info into separate optional groups in DeviceInfo counter
    - foldouts states in inspector are global now (thx AngryAnt!)
    - now most editor actions are undoable
    - improved example scene to let you tune more options
    - fixed and improved editor code which adds \ moves counter
    - fixed minor bugs
    - refactorings and minor code cleanup
    - fixes in docs

    Stay tuned, my TODO list became shorter but still has lots of great stuff!
     
    John-G likes this.
  33. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hi @Dmitriy Yukhanov I'm testing the latest 5.4 beta 10 and I'm getting a warning like this:



    Is that something you've addressed already in the new version of AFPS you just released? Or do you still have to address it?
     
  34. codestage

    codestage

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

    It should be fixed in latest released version, feel free to check it out and let me know how it works please =)
     
  35. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Yes, I confirm the latest published AFPS does not cause this warning anymore in 5.4. And great job with the display readability! :)
     
    codestage likes this.
  36. Mario_Basha

    Mario_Basha

    Joined:
    Jan 18, 2016
    Posts:
    14
    I've just bought this asset - and it is awesome! I am using it in mobile so would you please add "Device Model" to the Device info data - I think it is important. Thank you.
     
  37. codestage

    codestage

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

    Thanks for your purchase, and thanks for your feature request!
    I'll add option to show device model in next update.
     
    Mario_Basha likes this.
  38. Mario_Basha

    Mario_Basha

    Joined:
    Jan 18, 2016
    Posts:
    14
  39. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    I'd recommend disabling pixel perfect from the canvas, it causes large CPU spikes. Disabled it myself, but I'd say it would be smart to disable it by default.

    The shadow and outline are really slow too, but at least there's an option for them.
     
  40. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @iivo_k

    Thanks for your suggestion.
    I'll introduce an option for that in future update.
     
  41. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi @Dmitriy Yukhanov

    When I import into 5.3.4 I see the following error:

    Assets/CodeStage/AdvancedFPSCounter/Scripts/CountersData/MemoryCounterData.cs(301,55): error CS0117: `Profiler' does not contain a definition for `GetTotalReservedMemory'

    Never seen this before, so any ideas?

    thanks

    Nalin
     
  42. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @puzzlekings Hi Nalin!
    Are you sure you have no namespaceless Profiler class in your project?
     
  43. bryantdrewjones

    bryantdrewjones

    Joined:
    Aug 29, 2011
    Posts:
    147
    Hi @Dmitriy-Yukhanov :) Fantastic asset :) Just curious if there's an intended workflow for adding custom counters/data to the tool. It looks simple enough to just extend from BaseCounterData.cs, hardcode the new counter into AFPSCounter.cs, and then make any inspector changes to AFPSCounterEditor.cs, but that could be annoying if/when another update gets pushed out :oops:

    Anyway, I'm a big fan of this and Maintainer :) Thanks for sharing your work on the asset store :D
     
    codestage likes this.
  44. codestage

    codestage

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

    Thanks for your kind words =)

    Unfortunately currently AFPSCounter has no proper and flexible extension system, but it's on the TODO list and I'm going to implement something to make it easier to add new counters.

    I recently added custom temperature sensors readouts for the Android project the same way you described, so it's the only way to extend AFPSCounter now.
     
  45. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    302
    Does this work with Unity 5.4? I'm getting compile errors:



    The other three errors are similar - some issue with the Canvas class. What's happening?
     
  46. codestage

    codestage

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

    AFPSCounter works fine with Unity 5.4.
    These errors are from class Canvas in your project. Just put it into appropriate nameclass and errors should go away.
     
  47. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    302
    Thanks for the quick reply! But, sorry, what do you mean? Does AFPSCounter.cs need another "using" directive? It already has "using UnityEngine.UI".
     
  48. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    I meant looks like you have namespaceless class "Canvas" somewhere at your project thus it being put to the root global namespace interfering with Unity's builtin Canvas.
     
  49. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    302
    Awesome, just got it working. Thanks again.

    So, how does this work in play mode (rather than in a build)? Does it include the time spent rendering the Unity editor? Right now I'm getting three different values across the play mode Stats window, the Unity profiler, and Advanced FPS.
     
  50. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    It just shows actual FPS, like FRAPS and similar tools.