First try

This commit is contained in:
Thorbjoern
2025-06-28 16:40:31 +02:00
parent 4facf6a768
commit 643c071c51
40 changed files with 19460 additions and 1356 deletions
+49
View File
@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameStarter : MonoBehaviour
{
[SerializeField] int startScene = 1;
private int currentscene;
private int nextscene;
private void OnEnable()
{
StopRecordingTrigger.OnRecordStop += HandleRecordStop;
}
private void OnDisable()
{
StopRecordingTrigger.OnRecordStop -= HandleRecordStop;
}
private void Awake()
{
DontDestroyOnLoad(this);
currentscene = startScene;
}
// Update is called once per frame
void Update()
{
if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
{
if (SceneManager.GetActiveScene() != SceneManager.GetSceneByBuildIndex(startScene)) return;
nextscene = currentscene + 1;
currentscene = nextscene;
StartGameByLoadingScene(nextscene);
}
}
void StartGameByLoadingScene(int sceneIndex)
{
SceneManager.LoadScene(sceneIndex);
}
private void HandleRecordStop()
{
StartGameByLoadingScene(startScene);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e580ea451ce98a24b81fd7e238ac6393
@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class SpawnAtLongestEdge : MonoBehaviour
{
[SerializeField] GameObject roomPrefab;
[SerializeField] GameObject pointPrefab;
[SerializeField] GameObject reticlePrefab;
// Start is called before the first frame update
void Start()
{
// Prüfe, ob die Boundary aktiviert ist
if (OVRManager.boundary != null)
{
// Hole die Boundary-Geometrie (Play Area)
Vector3[] boundaryPoints = OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.PlayArea);
if (boundaryPoints != null && boundaryPoints.Length > 0)
{
Debug.Log("Boundary Points gefunden: " + boundaryPoints.Length);
AlignObjectToLongestEdge(boundaryPoints);
}
else
{
Debug.LogWarning("Keine Boundary Points gefunden.");
}
}
else
{
Debug.LogError("OVRManager.boundary ist nicht aktiviert.");
}
}
void AlignObjectToLongestEdge(Vector3[] boundaryPoints)
{
float maxLength = 0f;
Vector3 longestEdgeStart = Vector3.zero;
Vector3 longestEdgeEnd = Vector3.zero;
// Iteriere über die Punkte und finde die längste Kante
for (int i = 0; i < boundaryPoints.Length; i++)
{
Vector3 start = boundaryPoints[i];
Vector3 end = boundaryPoints[(i + 1) % boundaryPoints.Length]; // Modulo für den letzten Punkt
// Debug Visuals for Points
Instantiate(pointPrefab, start, Quaternion.LookRotation(end));
float length = Vector3.Distance(start, end);
if (length > maxLength)
{
maxLength = length;
longestEdgeStart = start;
longestEdgeEnd = end;
}
}
Debug.Log($"Längste Kante gefunden: Start({longestEdgeStart}), Ende({longestEdgeEnd}), Länge: {maxLength}");
// Richte dein Objekt aus
Vector3 midPoint = (longestEdgeStart + longestEdgeEnd) / 2;
Vector3 direction = (longestEdgeEnd - longestEdgeStart).normalized;
Instantiate(roomPrefab, midPoint, Quaternion.LookRotation(direction));
Transform reticle = Instantiate(reticlePrefab, longestEdgeStart, Quaternion.LookRotation(direction)).transform;
reticle.position = new Vector3 (reticle.position.x - 0.75f, reticle.position.y, reticle.position.z + 1);
// Beispiel: Objekt positionieren und ausrichten
//Transform objTransform = this.transform;
//objTransform.position = midPoint;
//objTransform.rotation = Quaternion.LookRotation(direction);
Debug.Log("Objekt wurde an der längsten Kante ausgerichtet.");
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 78d0b4c770471684b819e3235a0688bf
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System;
using UnityEngine;
public class StopRecordingTrigger : MonoBehaviour
{
public string tagFilter = "Player";
public static event Action OnRecordStop;
// Start is called once before the first execution of Update after the MonoBehaviour is created
private void OnTriggerEnter(Collider other)
{
if (!string.IsNullOrEmpty(tagFilter) && !other.gameObject.CompareTag(tagFilter)) return;
OnRecordStop.Invoke();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: edf374aa5a0a0cb4f9a7b1e7d4426155