-
Notifications
You must be signed in to change notification settings - Fork 0
Unity Analytics
This plugin supports Unity Analytics. When UniSwitcher detects that UA is enabled, it will send the 'ScreenVisit' event whenever PerformSceneTransition is called.
If you want to track scene switch events, it is strongly recommended to add UniSwitcher.Domain.IReportable to your BaseScene implementation.
Unity Analytics has a rate limit on the number of events sent per set amount of time.
Since UniSwitcher reports every scene change (its destination) using AnalyticsEvent.ScreenVisit by default, too many scene changes in a short period of time can easily cause the game to hit the rate limit. Such change can occur if you implement, e.g., a dialog scene that can occur multiple times.
By implementing IReportable, you can suppress the scene transition event being sent to Unity Analytics.
The interface IReportable requires implementing the DoNotReport method.
This method indicates Scenes that should not be reported of their transitions, e.g., scenes that contain dialogs.
public class Scene: BaseScene, IReportable
{
// Your implementation here
/// <summary>
/// If this returns true, DO NOT SEND ANALYTICS REPORT.
/// </summary>
/// <returns></returns>
public bool DoNotReport()
{
var self = this;
return NonReportingScenes().Any(scene => self == scene);
}
// Suppose that this is your pause dialog scene.
public static Scene PauseDialog => new Scene("pause_dialog.unity");
/// <summary>
/// Scenes you DON'T want to send analytics reports about
/// because e.g. it can be loaded in quick succession.
/// NOTE: This is just one way to implement this behavior;
/// if you have a better idea, you may use it instead.
/// </summary>
/// <returns></returns>
private static IEnumerable<Scene> NonReportingScenes()
{
// List all scenes you want to suppress using 'yield return.'
yield return PauseDialog;
}
}