Scripting 101

A guide on how to create your own records.

A record is a single entry that can track and contain data. Editor Statistics includes many built-in records such as Play Time, Session Count, Build Time, etc.

To create your own record, create a class that implements the IRecord interface.

using EditorStatistics;

public class MyRecord : IRecord
{
    
}

To add the record to the Editor Statistics window, add it to the EditorStats.Records list.

[InitializeOnLoadMethod]
static void Add()
{
    EditorStats.Records.Add(new MyRecord());
}

Here's the full code:

using EditorStatistics;
using UnityEditor;

public class MyRecord : IRecord
{
    [InitializeOnLoadMethod]
    static void Add()
    {
        EditorStats.Records.Add(new MyRecord());
    }
}

The displayed name of a record is based on its type.

Next Steps

You can implement other interfaces to extend your record's functionality. Here's an example how to use IValueRecordto add a value to your record:

using EditorStatistics;
using UnityEditor;

public class MyRecord : IRecord, IValueRecord
{
    [InitializeOnLoadMethod]
    static void Add()
    {
        EditorStats.Records.Add(new MyRecord());
    }

    public string GetValue()
    {
        return "My Value";
    }
}

Last updated