Made It Work
Various improvements in scripts and working with the old loding mechanism
This commit is contained in:
@@ -32,24 +32,25 @@ namespace GhostSystem
|
||||
|
||||
public static event Action OnRecord;
|
||||
public static event Action OnStopRecord;
|
||||
public static event Action OnUploadFinished;
|
||||
|
||||
private void Awake()
|
||||
/*private void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
}*/
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
SupabaseManager.OnSuperbaseReady += HandleSupabaseReady;
|
||||
RoomManager.OnSceneIdReady += HandleSceneIdReady;
|
||||
StopRecordingTrigger.OnRecordStop += HandleRecordStop;
|
||||
//StopRecordingTrigger.OnRecordStop += HandleRecordStop;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SupabaseManager.OnSuperbaseReady -= HandleSupabaseReady;
|
||||
RoomManager.OnSceneIdReady -= HandleSceneIdReady;
|
||||
StopRecordingTrigger.OnRecordStop -= HandleRecordStop;
|
||||
//StopRecordingTrigger.OnRecordStop -= HandleRecordStop;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -82,14 +83,14 @@ namespace GhostSystem
|
||||
doorCount++;
|
||||
}
|
||||
}
|
||||
StartRecording();
|
||||
//StartRecording();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleRecordStop()
|
||||
/*private void HandleRecordStop()
|
||||
{
|
||||
StopRecording();
|
||||
}
|
||||
}*/
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -135,12 +136,14 @@ namespace GhostSystem
|
||||
{
|
||||
Debug.LogWarning($"Batch insert failed: {response.ResponseMessage.StatusCode}, fallback to offline.");
|
||||
await FallbackToOfflineAsync(batch);
|
||||
OnUploadFinished?.Invoke();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Insert failed, fallback to offline: {ex.Message}");
|
||||
await FallbackToOfflineAsync(batch);
|
||||
OnUploadFinished?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +186,12 @@ namespace GhostSystem
|
||||
|
||||
doorCount = 0;
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
_flushTimer = 0f;
|
||||
_ = FlushBatchAsync(); // Fire and forget
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace GhostSystem
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
textbox.text += $"\n\rAuthentication failed: {ex}";
|
||||
textbox.text += "\n\rAuthentication failed";
|
||||
Debug.LogError($"❌ Authentication failed: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using GhostSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using TMPro;
|
||||
|
||||
public class FlushAndLoad : MonoBehaviour
|
||||
{
|
||||
public TMP_Text output;
|
||||
public GhostRecorderBatch recorder;
|
||||
public GameObject loadingScreen;
|
||||
public GameObject canvas;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
GhostRecorderBatch.OnUploadFinished += HandleUploadFinished;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GhostRecorderBatch.OnUploadFinished -= HandleUploadFinished;
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
|
||||
{
|
||||
output.text = "Flush...\n\r" + output.text;
|
||||
loadingScreen.SetActive(true);
|
||||
canvas.SetActive(false);
|
||||
|
||||
recorder.Flush();
|
||||
GetComponent<SceneLoader>().NewRoom();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleUploadFinished()
|
||||
{
|
||||
loadingScreen.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 787110b1243e93c4cbeda18e1c084baf
|
||||
Reference in New Issue
Block a user