Skip to main content

Class AttentionCheckService

Tracks how many attention checks the participant has failed and decides whether the session should be aborted when the threshold is exceeded.

[RequireComponent(typeof(GameInstance))]
public class AttentionCheckService : MonoBehaviour, IUnityGameService

Inheritance​

Implements​

IUnityGameService

Remarks​

Attention checks are periodic off-task questions (e.g. "What colour was the last traffic light?") injected by the research protocol to detect participants who are not genuinely engaging with the scenarios. Exceeding GetAllowedAttentionCheckAttempt failures triggers AttentionAbort, which loads the fail-screen scene and discards the session data, preventing unreliable observations from polluting the study dataset.

Properties​

AttentionCheckEnabled​

Indicates whether attention checks are globally enabled via the master toggle in Project Settings. When disabled, all attention check logic is bypassed regardless of in-game conditions.

public bool AttentionCheckEnabled { get; }

Property Value​

bool

Methods​

AttentionAbort()​

Triggers an abort by loading the fail scene defined in AttentionCheckSettings.

public void AttentionAbort()

IncrementAttentionCheckCounter(int)​

Increments the attention check failure counter by a specified amount.

public int IncrementAttentionCheckCounter(int amount)

Parameters​

NameTypeDescription
amountintThe amount to increment the counter by.

Returns​

int — The new attention check failure count.

IncrementAttentionCheckCounterByOne()​

Increments the attention check failure counter by one.

public int IncrementAttentionCheckCounterByOne()

Returns​

int — The new attention check failure count.

IsAttentionCheckStillAllowed()​

Determines whether the player is still allowed to proceed based on the current failure count and the allowed threshold defined in AttentionCheckSettings.

public bool IsAttentionCheckStillAllowed()

Returns​

bool — true if attention checks are disabled in project setting or the player is still within allowed attempts; otherwise, false.

  • Remarks
  • Properties
    • AttentionCheckEnabled
  • Methods
    • AttentionAbort()
    • IncrementAttentionCheckCounter(int)
    • IncrementAttentionCheckCounterByOne()
    • IsAttentionCheckStillAllowed()