66using System . Collections ;
77using UnityEngine . Events ;
88using System . Collections . Generic ;
9+ using UnityEngine . Serialization ;
910#if ENABLE_INPUT_SYSTEM
1011using UnityEngine . InputSystem ;
1112#endif
@@ -26,56 +27,76 @@ public enum MediaUploadType
2627
2728 public class BugReportUI : MonoBehaviour
2829 {
29- private static BugReportUI instance ;
30+ private static BugReportUI _instance ;
3031
31- public GameObject bugReportPanel ;
32- public TMP_InputField descriptionField ;
33- public TMP_InputField stepsField ;
32+ [ FormerlySerializedAs ( "bugReportPanel" ) ]
33+ public GameObject BugReportPanel ;
34+
35+ [ FormerlySerializedAs ( "descriptionField" ) ]
36+ public TMP_InputField DescriptionField ;
37+
38+ [ FormerlySerializedAs ( "stepsField" ) ]
39+ public TMP_InputField StepsField ;
3440
3541 public Toggle IncludeVideoToggle ;
3642 public Toggle IncludeScreenshotToggle ;
3743 public Toggle IncludePlayerLogToggle ;
3844
39- public Button submitButton ;
40- public Button closeButton ;
45+ [ FormerlySerializedAs ( " submitButton" ) ]
46+ public Button SubmitButton ;
4147
42- public GameObject messagePanel ;
48+ [ FormerlySerializedAs ( "closeButton" ) ]
49+ public Button CloseButton ;
4350
44- public MessagePanelUI messagePanelUI ;
51+ [ FormerlySerializedAs ( "messagePanel" ) ]
52+ public GameObject MessagePanel ;
53+
54+ [ FormerlySerializedAs ( "messagePanelUI" ) ]
55+ public MessagePanelUI MessagePanelUI ;
4556
4657 [ Tooltip ( "Upload in background : The media will be uploaded in the background without blocking the process" +
4758 " \n Wait for upload : The process will wait until the media has finished uploading before continuing" ) ]
48- public MediaUploadType mediaUploadType ;
59+ [ FormerlySerializedAs ( "mediaUploadType" ) ]
60+ public MediaUploadType MediaUploadType ;
4961
50- public ReportSubmittedUI reportSubmittedUI ;
62+ [ FormerlySerializedAs ( "reportSubmittedUI" ) ]
63+ public ReportSubmittedUI ReportSubmittedUI ;
5164
52- public string submitEndpoint = "https://app.betahub.io" ;
65+ [ FormerlySerializedAs ( "submitEndpoint" ) ]
66+ public string SubmitEndpoint = "https://app.betahub.io" ;
5367
54- public string projectID ;
68+ [ FormerlySerializedAs ( "projectID" ) ]
69+ public string ProjectID ;
5570
56- public string authToken ;
71+ [ FormerlySerializedAs ( "authToken" ) ]
72+ public string AuthToken ;
5773
5874 // If set, this email address will be used as the default email address of the reporter.
5975 // This is a hidden field since it's purpose is to be pre-filled programmatically by the developer if the user is somehow already logged in with a specific email address.
60- [ HideInInspector ]
61- public string defaultEmailAddress ;
76+ [ HideInInspector , FormerlySerializedAs ( "defaultEmailAddress" ) ]
77+ public string DefaultEmailAddress ;
6278
6379 #if ENABLE_INPUT_SYSTEM
64- public InputAction shortcutAction = new InputAction ( "BugReportShortcut" , binding : "<Keyboard>/f12" ) ;
80+ [ FormerlySerializedAs ( "shortcutAction" ) ]
81+ public InputAction ShortcutAction = new InputAction ( "BugReportShortcut" , binding : "<Keyboard>/f12" ) ;
6582 #else
66- public KeyCode shortcutKey = KeyCode . F12 ;
83+ [ FormerlySerializedAs ( "shortcutKey" ) ]
84+ public KeyCode ShortcutKey = KeyCode . F12 ;
6785 #endif
6886
69- public bool includePlayerLog = true ;
70- public bool includeVideo = true ;
87+ [ FormerlySerializedAs ( "includePlayerLog" ) ]
88+ public bool IncludePlayerLog = true ;
89+
90+ [ FormerlySerializedAs ( "includeVideo" ) ]
91+ public bool IncludeVideo = true ;
7192
7293 public UnityEvent OnBugReportWindowShown ;
7394 public UnityEvent OnBugReportWindowHidden ;
7495
7596 private List < Issue . ScreenshotFileReference > _screenshots = new List < Issue . ScreenshotFileReference > ( ) ;
7697 private List < Issue . LogFileReference > _logFiles = new List < Issue . LogFileReference > ( ) ;
7798
78- private static Logger logger ;
99+ private static Logger _logger ;
79100 private bool _cursorStateChanged ;
80101 private CursorLockMode _previousCursorLockMode ;
81102
@@ -87,14 +108,14 @@ public class BugReportUI : MonoBehaviour
87108 [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . SubsystemRegistration ) ]
88109 private static void InitializeLogger ( )
89110 {
90- logger = new Logger ( ) ;
111+ _logger = new Logger ( ) ;
91112 }
92113
93114 void Awake ( )
94115 {
95- if ( instance == null )
116+ if ( _instance == null )
96117 {
97- instance = this ;
118+ _instance = this ;
98119 }
99120 else
100121 {
@@ -128,25 +149,25 @@ void Start()
128149 {
129150 _gameRecorder = GetComponent < GameRecorder > ( ) ;
130151
131- bugReportPanel . SetActive ( false ) ;
132- submitButton . onClick . AddListener ( SubmitBugReport ) ;
133- closeButton . onClick . AddListener ( ( ) =>
152+ BugReportPanel . SetActive ( false ) ;
153+ SubmitButton . onClick . AddListener ( SubmitBugReport ) ;
154+ CloseButton . onClick . AddListener ( ( ) =>
134155 {
135- bugReportPanel . SetActive ( false ) ;
156+ BugReportPanel . SetActive ( false ) ;
136157 } ) ;
137158
138- if ( string . IsNullOrEmpty ( projectID ) )
159+ if ( string . IsNullOrEmpty ( ProjectID ) )
139160 {
140161 Debug . LogError ( "Project ID is not set. I won't be able to submit bug reports." ) ;
141162 }
142163
143- if ( string . IsNullOrEmpty ( authToken ) )
164+ if ( string . IsNullOrEmpty ( AuthToken ) )
144165 {
145166 Debug . LogError ( "Auth token is not set. I won't be able to submit bug reports." ) ;
146167 }
147168
148169 // auth token must start with tkn-
149- if ( ! authToken . StartsWith ( "tkn-" ) )
170+ if ( ! AuthToken . StartsWith ( "tkn-" ) )
150171 {
151172 Debug . LogError ( "Auth token must start with tkn-. I won't be able to submit bug reports." ) ;
152173 }
@@ -190,17 +211,17 @@ void Update()
190211 }
191212 }
192213
193- if ( bugReportPanel . activeSelf && ! _cursorStateChanged )
214+ if ( BugReportPanel . activeSelf && ! _cursorStateChanged )
194215 {
195216 ModifyCursorState ( ) ;
196217 }
197- else if ( ! bugReportPanel . activeSelf && ! messagePanelUI . gameObject . activeSelf && _cursorStateChanged )
218+ else if ( ! BugReportPanel . activeSelf && ! MessagePanelUI . gameObject . activeSelf && _cursorStateChanged )
198219 {
199220 RestoreCursorState ( ) ;
200221 }
201222
202223 #if ! ENABLE_INPUT_SYSTEM
203- if ( shortcutKey != KeyCode . None && Input . GetKeyDown ( shortcutKey ) )
224+ if ( ShortcutKey != KeyCode . None && Input . GetKeyDown ( ShortcutKey ) )
204225 {
205226 StartCoroutine ( CaptureScreenshotAndShowUI ( ) ) ;
206227 }
@@ -210,7 +231,7 @@ void Update()
210231 private bool SholdBeRecordingVideo ( )
211232 {
212233 // if true, the report is being uploaded, some processes should be paused
213- return includeVideo && ! bugReportPanel . activeSelf && ! _issues . Exists ( issue => ! issue . IsMediaUploadComplete ) ;
234+ return IncludeVideo && ! BugReportPanel . activeSelf && ! _issues . Exists ( issue => ! issue . IsMediaUploadComplete ) ;
214235 }
215236
216237 private void ModifyCursorState ( )
@@ -261,20 +282,20 @@ IEnumerator CaptureScreenshotAndShowUI()
261282 yield return null ;
262283
263284 // reset the fields
264- descriptionField . text = "" ;
265- stepsField . text = "" ;
285+ DescriptionField . text = "" ;
286+ StepsField . text = "" ;
266287 IncludeVideoToggle . isOn = true ;
267288 IncludeScreenshotToggle . isOn = true ;
268289 IncludePlayerLogToggle . isOn = true ;
269290
270291 #if BETAHUB_DEBUG
271292 Debug . Log ( "BETAHUB_DEBUG: Prefilling description and steps for reproduce for faster testing" ) ;
272293 // prefill the description and steps for reproduce for faster testing
273- descriptionField . text = "The game is crashing when I press the sounds setting button. It happens on the main menu and on the settings menu." ;
274- stepsField . text = "1. Go to the main menu\n 2. Press the settings button\n 3. Press the sounds button\n 4. Crash the game" ;
294+ DescriptionField . text = "The game is crashing when I press the sounds setting button. It happens on the main menu and on the settings menu." ;
295+ StepsField . text = "1. Go to the main menu\n 2. Press the settings button\n 3. Press the sounds button\n 4. Crash the game" ;
275296 #endif
276297
277- bugReportPanel . SetActive ( true ) ;
298+ BugReportPanel . SetActive ( true ) ;
278299 }
279300
280301 // Sets screenshot path to be uploaded. Useful on manual invocation of bug report UI.
@@ -290,8 +311,8 @@ public void AddLogFile(string path, bool removeAfterUpload)
290311
291312 void SubmitBugReport ( )
292313 {
293- string description = descriptionField . text ;
294- string steps = stepsField . text ;
314+ string description = DescriptionField . text ;
315+ string steps = StepsField . text ;
295316
296317 // Filter screenshots and logs based on toggle state
297318 List < Issue . ScreenshotFileReference > screenshots = null ;
@@ -309,45 +330,45 @@ void SubmitBugReport()
309330 logFiles = new List < Issue . LogFileReference > ( _logFiles ) ;
310331
311332 // Add logger log file if it exists
312- if ( includePlayerLog && ! string . IsNullOrEmpty ( logger . LogPath ) && File . Exists ( logger . LogPath ) )
333+ if ( IncludePlayerLog && ! string . IsNullOrEmpty ( _logger . LogPath ) && File . Exists ( _logger . LogPath ) )
313334 {
314335 // skip if size over 200MB
315- if ( new FileInfo ( logger . LogPath ) . Length < 200 * 1024 * 1024 )
336+ if ( new FileInfo ( _logger . LogPath ) . Length < 200 * 1024 * 1024 )
316337 {
317- logFiles . Add ( new Issue . LogFileReference { path = logger . LogPath , removeAfterUpload = false } ) ;
338+ logFiles . Add ( new Issue . LogFileReference { path = _logger . LogPath , removeAfterUpload = false } ) ;
318339 }
319340 }
320341 }
321342
322- if ( includeVideo && IncludeVideoToggle . isOn )
343+ if ( IncludeVideo && IncludeVideoToggle . isOn )
323344 {
324345 gameRecorder = _gameRecorder ;
325346 }
326347
327348 // Create Issue instance and post it
328- Issue issue = new Issue ( submitEndpoint , projectID , authToken , messagePanelUI , reportSubmittedUI , gameRecorder ) ;
349+ Issue issue = new Issue ( SubmitEndpoint , ProjectID , AuthToken , MessagePanelUI , ReportSubmittedUI , gameRecorder ) ;
329350 _issues . Add ( issue ) ;
330351
331352
332353 Action < ErrorMessage > onIssueError = ( ErrorMessage errorMessage ) =>
333354 {
334355 try {
335356 // error, get ready to try again
336- submitButton . interactable = true ;
337- submitButton . GetComponentInChildren < TMP_Text > ( ) . text = "Submit" ;
357+ SubmitButton . interactable = true ;
358+ SubmitButton . GetComponentInChildren < TMP_Text > ( ) . text = "Submit" ;
338359
339360 if ( errorMessage . exception != null )
340361 {
341362 Debug . LogError ( "Error submitting bug report: " + errorMessage . exception ) ;
342- messagePanelUI . ShowMessagePanel ( "Error" , "Error submitting bug report. Please try again later." ) ;
363+ MessagePanelUI . ShowMessagePanel ( "Error" , "Error submitting bug report. Please try again later." ) ;
343364 }
344365 else if ( ! string . IsNullOrEmpty ( errorMessage . error ) )
345366 {
346- messagePanelUI . ShowMessagePanel ( "Error" , errorMessage . error ) ;
367+ MessagePanelUI . ShowMessagePanel ( "Error" , errorMessage . error ) ;
347368 }
348369 else
349370 {
350- messagePanelUI . ShowMessagePanel ( "Error" , "Unknown error submitting bug report. Please try again later." ) ;
371+ MessagePanelUI . ShowMessagePanel ( "Error" , "Unknown error submitting bug report. Please try again later." ) ;
351372 }
352373 }
353374 catch ( Exception e )
@@ -361,20 +382,20 @@ void SubmitBugReport()
361382 issue . PostIssue ( description , steps , screenshots , logFiles , false ,
362383 ( issueId ) => // successful post
363384 {
364- submitButton . interactable = true ;
365- submitButton . GetComponentInChildren < TMP_Text > ( ) . text = "Submit" ;
385+ SubmitButton . interactable = true ;
386+ SubmitButton . GetComponentInChildren < TMP_Text > ( ) . text = "Submit" ;
366387
367388 // Clear lists after successful upload
368389 _screenshots . Clear ( ) ;
369390 _logFiles . Clear ( ) ;
370391
371392 // show the report submitted UI
372- reportSubmittedUI . Show ( issue , defaultEmailAddress ) ;
393+ ReportSubmittedUI . Show ( issue , DefaultEmailAddress ) ;
373394
374395 // hide bug report panel
375- bugReportPanel . SetActive ( false ) ;
396+ BugReportPanel . SetActive ( false ) ;
376397 } ,
377- mediaUploadType ,
398+ MediaUploadType ,
378399 ( error ) =>
379400 {
380401 onIssueError ( new ErrorMessage { error = error } ) ;
@@ -388,8 +409,8 @@ void SubmitBugReport()
388409 }
389410 } ) ;
390411
391- submitButton . interactable = false ;
392- submitButton . GetComponentInChildren < TMP_Text > ( ) . text = "Submitting..." ;
412+ SubmitButton . interactable = false ;
413+ SubmitButton . GetComponentInChildren < TMP_Text > ( ) . text = "Submitting..." ;
393414 }
394415
395416 class ErrorMessage {
0 commit comments