You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-2Lines changed: 25 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,10 @@ API_KEY=your-admin-key
91
91
92
92
Only the endpoint `/api/testers/validate-access` is publicly accessible for validating tester access, and `/api/testers/{accessKey}/playtime` is publicly accessible for reporting accumulated playtime.
93
93
94
+
## 📘 HTTP Request Examples
95
+
96
+
You can use this [Playtesters.API.http](https://github.com/DevD4v3/Playtesters.API/blob/master/src/Playtesters.API.http) file (VS Code / Rider / Visual Studio compatible) to test every endpoint of the API.
97
+
94
98
## 🎮Unity Integration
95
99
96
100
- The `/api/testers/validate-access` endpoint should be called before allowing gameplay or enabling private build features to ensure the tester has valid access.
@@ -102,9 +106,28 @@ Below is a quick demonstration of how you can integrate the Playtesters API into
We provide two ready-to-use scripts in `assets/unity/`:
106
111
107
-
You can use this [Playtesters.API.http](https://github.com/DevD4v3/Playtesters.API/blob/master/src/Playtesters.API.http) file (VS Code / Rider / Visual Studio compatible) to test every endpoint of the API.
112
+
1.**TesterLoginMenu.cs** – Handles tester login and access key validation.
113
+
- Sends the access key entered by the tester to the `/api/testers/validate-access` endpoint.
114
+
- Handles success and error responses from the API, including invalid keys and server errors.
115
+
- Implements a **cooldown mechanism** after a configurable number of failed attempts.
116
+
- On successful login, triggers the `PlaytimeReporter` to start reporting playtime and can load the main menu or other gameplay scenes.
117
+
- Fully integrates with Unity UI using `TMP_InputFields` and `TMP_Text` for user feedback.
118
+
119
+
2.**PlaytimeReporter.cs** – Reports playtime increments to the backend.
120
+
- Sends the number of hours played **since the last report** to `/api/testers/{accessKey}/playtime`.
121
+
- The script **does not send the total playtime since login**, because the backend already keeps a record of total accumulated playtime.
122
+
Sending the total from the start of the session would **double-count** the time.
123
+
- Each report calculates the time difference from the last report (`_lastReportTime`) and updates `_lastReportTime` after sending.
124
+
- By default, reports are sent every 2 minutes (`_reportIntervalSeconds`), but this can be configured via the Inspector.
125
+
- Can be attached to a persistent GameObject (`DontDestroyOnLoad`) so it continues reporting across scenes.
0 commit comments