C# API Reference (Unity)

All APIs are static methods of the Gamebench class in the GamebenchLib.Runtime namespace. You do not need to instantiate anything.

If you want to start and stop sessions using these APIs remember to disable automatic capture via the option in the GameBench configuration panel in the Unity Editor.

Sessions

void Start(string sessionTitle = null)
Starts a new capture session, with an optional title.

string GetSessionId()
Returns the UUID of the active session, or null if there isn’t one.

void Stop()
Stops the current capture session.

void Reset()
Deletes all GameBench data in the app. Must be called without an active session.

void Upload(UploadCallback callback = null)
Uploads any outstanding sessions to the endpoint configured in the UI. After successful upload the session data will be removed from the device. Must be called without an active session.

NB: The signature of the optional callback is delegate void UploadCallback(int numSessionsUploaded, string errorMessage).

Metric capture

All metrics may be captured at set intervals and/or with the CaptureNow() method. Metric capture has very low overhead and is asynchronous, it should not affect your app’s observed performance.

void SetCaptureInterval(MetricType, float)
Enable and set the capture interval in seconds for the given metric type. Can be called with or without an active capture session. Use an interval of 0 or less to disable.

void CaptureNow(MetricType)
Capture and write out the given metric now.

Note that screenshots are a type of metric (see the SS values in the MetricType enum). To capture a screenshot at 50% the screen resolution you could write CaptureNow(MetricType.SS1).

Markers

To isolate specific areas of gameplay such as levels or battles, GameBench provides markers functionality. For example, to isolate performance data during a particular game level, you can call MarkStart() when the level begins and MarkStop() when the level is completed.

void MarkStart(string name, string group = null)
Record a ‘start’ marker with the given name and marker group (optional).

void MarkStop(string name, string group = null)
Record a ‘stop’ marker with the given name.

void MarkLaunchComplete()
Record a ’launch complete’ marker that has special significance in the web dashboard.

NB: Markers for Unity scene changes are recorded automatically by default.

Tags

void SetTag(string name, string value)
Set a tag in the tags collection

RemoveTag(string)
Remove a tag from the tags collection

Other Configuration

All other configuration values are also settable in code. Note that these values set with these APIs are transient and do not persist beyond process exit.

void SetConfigItem(ConfigItem, string | bool)
Set a configuration value where ConfigItem is a value from the following enum in the same namespace as Gamebench:

    public enum ConfigItem {
        UploadUrl,        // string
        UploadEmail,      // string
        UploadToken,      // string
        AutoSession,      // bool
        MarkSceneChanges, // bool
        VerboseLogging,   // bool
    }
Last updated on