Added Observation Scene to show the Replay

This commit is contained in:
Thorbjoern
2025-05-26 18:56:25 +02:00
parent 37c6bd8269
commit c304bc0e10
211 changed files with 60070 additions and 14 deletions
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System;
using System.Reactive;
using UnityEngine.UI;
using Postgrest;
namespace GhostSystem
{
@@ -30,6 +31,8 @@ namespace GhostSystem
private bool isPlaying = false;
private float playbackTime = 0f;
private float totalDuration = 0f;
private string firstTimestamp = "";
private string lastTimestamp = "";
private Dictionary<string, List<FrameModel>> objectTracks = new();
@@ -82,6 +85,8 @@ namespace GhostSystem
public async Task LoadFrames()
{
Debug.Log("SceneId used in query: " + SceneId);
Debug.Log("StartTime filter: " + dateSelector.selectedDateTime().ToString("o"));
var query = SupabaseManager.instance.supabase
.From<FrameModel>()
@@ -115,6 +120,8 @@ namespace GhostSystem
if (frames.Count > 1)
{
totalDuration = (float)(frames.Last().TimestampParsed - frames.First().TimestampParsed).TotalSeconds;
firstTimestamp = frames.First().TimestampParsed.ToLongTimeString();
lastTimestamp = frames.Last().TimestampParsed.ToLongTimeString();
}
}
@@ -122,7 +129,7 @@ namespace GhostSystem
{
isPlaying = true;
playbackTime = 0f;
Debug.LogError("Replay started: total duration = " + totalDuration);
Debug.LogError("Replay started: total duration = " + totalDuration + " s, First: " + firstTimestamp + ", Last: " + lastTimestamp);
}
public void PauseReplay() => isPlaying = false; // Für das Pause UI-Element, um das Replay zu pausieren
@@ -202,12 +209,6 @@ namespace GhostSystem
}
}
/*public void OnSliderValueChanged(float value)
{
if (totalDuration <= 0f) return;
isScrubbing = true;
SetPlaybackTime(value * totalDuration);
}*/
public void SetSliderScrubValue(float sliderValue)
{
if (isScrubbing)
@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
public class FillDopdownWithScenes : MonoBehaviour
{
public TMP_Dropdown dropdown;
private void Awake()
{
PopulateWithScenes();
}
void PopulateWithScenes()
{
dropdown.ClearOptions();
List<string> sceneNames = new List<string>();
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
{
string path = SceneUtility.GetScenePathByBuildIndex(i);
string name = System.IO.Path.GetFileNameWithoutExtension(path);
sceneNames.Add(name);
}
dropdown.AddOptions(sceneNames);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6c27d5a2aeea111429f65ac2225a36c6
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class FillDropdownWithDays : MonoBehaviour
{
public TMP_Dropdown dropdown;
Dictionary<int, int> daysPerMonth = new Dictionary<int, int>();
private void Awake()
{
daysPerMonth.Add(0, 31);
daysPerMonth.Add(1, 29);
daysPerMonth.Add(2, 31);
daysPerMonth.Add(3, 30);
daysPerMonth.Add(4, 31);
daysPerMonth.Add(5, 30);
daysPerMonth.Add(6, 31);
daysPerMonth.Add(7, 31);
daysPerMonth.Add(8, 30);
daysPerMonth.Add(9, 31);
daysPerMonth.Add(10, 30);
daysPerMonth.Add(11, 31);
}
public void FillDropdown(int month)
{
dropdown.ClearOptions();
List<string> days = new List<string>();
for (int i = 0; i < daysPerMonth[month]; i++)
{
days.Add((i+1).ToString());
}
dropdown.AddOptions(days);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5f79fe3d9f0326c4d959fe6de8bcac3a
@@ -0,0 +1,22 @@
using GhostSystem;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ReplaySceneLoader : MonoBehaviour
{
public GhostReplayManager replayManager;
private int currentScene;
public void LoadSceneAdditive(int sceneIndex)
{
if(SceneManager.loadedSceneCount > 1)
{
SceneManager.UnloadSceneAsync(currentScene);
}
SceneManager.LoadSceneAsync(sceneIndex, LoadSceneMode.Additive);
currentScene = sceneIndex;
// replayManager.SceneId = SceneManager.GetSceneByBuildIndex(currentScene).name; wird jetzt durch Event der Szene gelöst
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3d74842cc0a4f48419177a183e13859e