Debug screen log in PlayCanvas project

Created a debug logger, semi-automatic, it only works for a couple of values (number, bool, string, vector) and it always accepts string (thought it doesn’t check if it is a string) as the first value and data to write as a second.

Edit: Actually made it work with many variables (pass it as an array).

Sorry, I know close to zero when it comes to JS so this was quite fun to do it in free time (today). Will probably continue messing around :slight_smile:

Here is a link to project if someone is bored enough, hehe
https://playcanvas.com/project/940364/overview/spartox

3 Likes

Did some improvements, it’s actually not that hard to mess around with the data for every object. Added some stuff:

  • I can add an array of values (not all of them, will never need all of them…).
  • I can add custom color if I want.
  • Can change if the text will be deleted or not (if the number of texts reach certain number…it would automatically get deleted.
  • Can adjust the time before it getting deleted.
  • Default values (if not all are provided) that can be adjusted on the “DebugLog” template and saved.

No idea why I am doing this but it is really fun.

Kind of hard to see the letters but will probably add the black image element to act as a parent of the text element.

1 Like

Since I want my project to be some kind of grid movement explore/combat…started creating Debug for Grid (for easier pathfinding debugging).

Still a lot of work to be done but this was a really nice experience:

  • Node/Cell will be used for editor only…build won’t include them of course.
  • For now it’s manual creation of the feature (there is only so many hours and free time that I have).
  • The debug boxes are pooled on start and in Idle state checked if there are enough of them.
  • In Move state the boxes are just disabled (hence… pooling).

Still want to add a lot more things to it before committing to pathfinding algorithm, like:

  • Create a debugBox attributes in editor for easier debugging (like for debugLogger).
  • Some performance optimization, like deleting every bDebug variable if it’s turned off, etc.
  • Want to create comments for all of the debugBox and debugLog methods…they do need them, was lazy.
  • Better way to use ternary operator since I don’t want to use “let _” every time.
  • More but too tired to think… sorry.

Having a blast learning JS by doing things in the engine, thanks for creating it!

1 Like