Skip to content
Snippets Groups Projects
Commit 95aa4132 authored by JonuziFlorina's avatar JonuziFlorina
Browse files

fixed multiple choice buttons & some other relevant fixings

parent 05b219ea
No related branches found
No related tags found
No related merge requests found
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using static UnityEngine.InputSystem.HID.HID;
public class Antwort1 : MonoBehaviour
{
public Button Antworteins;
public Button Antwortzwei; //richtige Antwort
public Button Antwortdrei;
public Color correctAnswerColor = Color.green;
public Color falseAnswerColor = Color.red;
// Start is called before the first frame update
void Start()
{
private void OnAntwortzweiClicked()
{
Debug.Log("Ja Button geklickt");
Antwortzwei.GetComponent<Image>().color = correctAnswerColor; // Markiere JA Button grn
// Optional: Zeige eine Nachricht an oder fhre eine weitere Aktion aus
}
private void OnAntworteinsClicked()
{
Debug.Log("Nein Button geklickt");
Antworteins.GetComponent<Image>().color = falseAnswerColor;
}
}
// Update is called once per frame
void Update()
{
}
}
......@@ -7,6 +7,7 @@ using TMPro;
public class Laptop : MonoBehaviour, IMixedRealityTouchHandler
{
public List<GameObject> uiElements; // Liste fr alle bergeordneten UI-Elemente (TextMeshPro und Buttons)
private Coroutine hideCoroutine; // Coroutine-Referenz zum Verwalten des Timers
void Start()
{
......@@ -15,16 +16,32 @@ public class Laptop : MonoBehaviour, IMixedRealityTouchHandler
public void OnTouchStarted(HandTrackingInputEventData eventData)
{
SetElementsVisibility(true); // Sichtbar machen
// Sichtbar machen
SetElementsVisibility(true);
// Bestehende Coroutine stoppen, falls vorhanden
if (hideCoroutine != null)
{
StopCoroutine(hideCoroutine);
}
// Neue Coroutine starten
hideCoroutine = StartCoroutine(HideElementsAfterDelay(10f)); // 10 Sek Verzgerung
}
public void OnTouchCompleted(HandTrackingInputEventData eventData)
{
SetElementsVisibility(false); // Wieder unsichtbar machen
}
public void OnTouchUpdated(HandTrackingInputEventData eventData) { }
IEnumerator HideElementsAfterDelay(float delay)
{
yield return new WaitForSeconds(delay);
SetElementsVisibility(false);
}
void SetElementsVisibility(bool isVisible)
{
foreach (var element in uiElements)
......@@ -49,7 +66,7 @@ public class Laptop : MonoBehaviour, IMixedRealityTouchHandler
renderer.enabled = isVisible;
}
// Weitere UI-Komponenten
// Weitere UI-Komponenten
var graphic = obj.GetComponent<UnityEngine.UI.Graphic>();
if (graphic != null)
{
......@@ -63,3 +80,5 @@ public class Laptop : MonoBehaviour, IMixedRealityTouchHandler
}
}
}
using UnityEngine;
using UnityEngine.UI;
public class Notiz : MonoBehaviour
{
public Button Antworteins;
public Button Antwortzwei; // Richtige Antwort
public Button Antwortdrei;
public Color correctAnswerColor = Color.green;
public Color falseAnswerColor = Color.red;
void Start()
{
Antwortzwei.onClick.AddListener(OnAntwortzweiClicked);
Antworteins.onClick.AddListener(OnAntworteinsClicked);
}
private void OnAntwortzweiClicked()
{
Debug.Log("Antwort zwei Button geklickt");
Transform frontPlateTransform = Antwortzwei.transform.Find("ButtonContent/CompressableButtonVisuals/FrontPlate");
if (frontPlateTransform != null)
{
Image frontPlateImage = frontPlateTransform.GetComponent<Image>();
if (frontPlateImage != null)
{
frontPlateImage.color = correctAnswerColor;
Debug.Log("Farbe gendert zu Grn");
}
else
{
Debug.LogError("Image component not found on FrontPlate!");
}
}
else
{
Debug.LogError("FrontPlate not found!");
}
}
private void OnAntworteinsClicked()
{
Debug.Log("Antwort eins Button geklickt");
Transform frontPlateTransform = Antworteins.transform.Find("ButtonContent/CompressableButtonVisuals/FrontPlate");
if (frontPlateTransform != null)
{
Image frontPlateImage = frontPlateTransform.GetComponent<Image>();
if (frontPlateImage != null)
{
frontPlateImage.color = falseAnswerColor;
Debug.Log("Farbe gendert zu Rot");
}
else
{
Debug.LogError("Image component not found on FrontPlate!");
}
}
else
{
Debug.LogError("FrontPlate not found!");
}
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment