Grapher - Graphical Debugging, Logging and Replay

Grapher is an editor extension to help with debugging and analysis of variables.
It can visualise multiple variables in a form of a graph, log them to a file and replay them in the exact manner.

Features:

  • Supports multiple types: int, float (double, long), enum, Vector2, Vector3, List, Array, Queue
  • Single line use - no fuss, no initialization or cleanup required.
  • Graph, log to file and console debug at the same time
  • Logging to CSV - can be imported to spreadsheet programs or replayed inside Grapher.
  • Replay (from file or instant) - after exiting play mode graph can be immediately replayed or replayed later from the recorded .csv file.
  • Automatic scaling - if enabled, graph will be scaled along Y axis to fit the viewport (per channel or linked).
  • Adjustable time range - from 0.5 to 40 seconds, depending on needed time resolution.

Only one line is needed for it to work, and there are a few overloads such as:

Grapher.Log(cos, "Cos");
Grapher.Log(cos, 1);
Grapher.Log(cos, "Cos", Color.red);

This is the result of running a few Grapher.Log()s in the play mode (notice the LIVE text in the top left). Bring up Grapher by pressing “Ctrl + G” (or Mac OSX equivalent) or dock the window and this is the result:

This is the same graph but but being replayed from the recorded file(s):

Each variable is being logged into an individual .csv file (if logging is enabled for that variable, little save icon next to the name). It is possible to load any number of different .csv files and have them play at the same time. More files can be added even while replay is on. To speed things up all the files from the same session (from pressing play to stopping) are also added to a .ses file. Opening those loads all the variables from that session simultaneously, although you could open them one by one if you wanted to do so.

Example logging output:
2983849--221973--upload_2017-3-7_0-21-19.png

S699 represents session number, and the number at the end is a timestamp. Grapher can be configured in settings to overwrite files in which case the name will not be unique, e.g. Cos1.csv.

Grapher will be available on the Unity Asset Store in about 10 days.

Any suggestions are welcome!

1 Like

Update on the progress:

  • Added support for more types:
    Vector2, Vector3, List, Array, Queue, ArrayList and other IEnumerables

  • Better logging to console.
    (item is displayed as Debug.Log in the following format if “Log To Console” icon is clicked for that chanel):
    2986624--222261--upload_2017-3-9_0-42-1.png

  • Added settings:
    2986624--222262--upload_2017-3-9_0-43-28.png

  • Added optional “Shared Y Range” which enables all the channels to scale proportionately, result:

  • Code optimization: now takes about 2ms per channel.

Looks very handy!

1 Like

I have just submitted the package after some more improvements and fixes, so it should be out soon. Asset Store review times seem to be random at best.

I can only see the graph in the Editor Window.
How can I describe the graph created by Grapher in my GameScreen?

Note that Grapher is editor exension which means that it can only be used inside editor. No editor exensions can be used in game view itself.

Update 1.1 is out with updated instructions for newer versions of Unity.

Hi,

how can I use your graph within a component since within a component script, Grapher is not accessible ? I am struggling to find the best way to use grapher in that context.

Thanks :slight_smile:

Bye,

Jean

Hello,
sorry for not responding earlier, I was on mobile for the whole week and Unity forums seem to randomly not send notifications to my mail.
Check the first post in here for usage. If the Grapher has been properly imported you can use it just like you would use Unity’s Debug class since it is a static class.

Hi,

uhm I see, it’s because of the misleading documentation that says to move Grapher inside an Editor folder. If you move a script inside an Editor folder, then it’s inaccessible from a regular component.

Would it not make more sense to use scripting symbols so that you can have Grapher in your assets and would not cause any trouble when compiling using #IF UNITY_EDITOR ?

Bye,

Jean

Sorry for the documentation, this is a leftover from Unity <2017 versions where this was the case.

Grapher is great. It works well, in the Editor, with only one line of code.
Well done.

However, I now have an issue when I try to build my game:

Assets/Grapher/Grapher.cs(12,32): error CS0246: The type or namespace name ‘EditorWindow’ could not be found (are you missing a using directive or an assembly reference?)

How do I tell Unity3D to build my game without Grapher?

Hello,
that is an error on my part. Placing Grapher into Editor folder should solve the problem as anything that is in Editor does not get built.

If I do that, then Grapher is no longer found for the editor build.

I tried Editor.Grapher but that didn’t work. Do I need a ‘using directive’ somewhere?

Could I ask what version of Unity you are using so I can replicate this?
If the editor folder does not work one way to fix this would be to put whole problematic class under “#if UNITY_EDITOR” directive.