Skip to content
Snippets Groups Projects
Commit 05b219ea authored by thielicke's avatar thielicke
Browse files

Buttons + Skript Notizzettel, Whiteboard, Envelopes

parent 9474e654
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()
{
}
}
fileFormatVersion: 2
guid: bc02914fe7e660e4f9c2cef7a4631997
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using Microsoft.MixedReality.Toolkit.Input;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Envelopes : MonoBehaviour, IMixedRealityTouchHandler
{
public List<GameObject> uiElements; // Liste fr alle bergeordneten UI-Elemente (TextMeshPro und Buttons)
void Start()
{
SetElementsVisibility(false); // Initial unsichtbar
}
public void OnTouchStarted(HandTrackingInputEventData eventData)
{
SetElementsVisibility(true); // Sichtbar machen
}
public void OnTouchCompleted(HandTrackingInputEventData eventData)
{
SetElementsVisibility(false); // Wieder unsichtbar machen
}
public void OnTouchUpdated(HandTrackingInputEventData eventData) { }
void SetElementsVisibility(bool isVisible)
{
foreach (var element in uiElements)
{
SetVisibilityRecursive(element, isVisible);
}
}
void SetVisibilityRecursive(GameObject obj, bool isVisible)
{
// TextMeshPro-Komponente
TextMeshPro textMeshPro = obj.GetComponent<TextMeshPro>();
if (textMeshPro != null)
{
textMeshPro.color = new Color(textMeshPro.color.r, textMeshPro.color.g, textMeshPro.color.b, isVisible ? 1.0f : 0.0f);
}
// Renderer-Komponente (fr andere visuelle Elemente)
Renderer renderer = obj.GetComponent<Renderer>();
if (renderer != null)
{
renderer.enabled = isVisible;
}
// Weitere UI-Komponenten
var graphic = obj.GetComponent<UnityEngine.UI.Graphic>();
if (graphic != null)
{
graphic.color = new Color(graphic.color.r, graphic.color.g, graphic.color.b, isVisible ? 1.0f : 0.0f);
}
// Rekursiv fr alle Kinderobjekte
foreach (Transform child in obj.transform)
{
SetVisibilityRecursive(child.gameObject, isVisible);
}
}
}
fileFormatVersion: 2
guid: f638cdf1ea6408940b6462d3c0d878f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -6,34 +6,60 @@ using TMPro;
public class Notizzettel : MonoBehaviour, IMixedRealityTouchHandler
{
public TextMeshPro textMesh;
public List<GameObject> uiElements; // Liste fr alle bergeordneten UI-Elemente (TextMeshPro und Buttons)
void Start()
{
SetTextVisibility(false); // Initial unsichtbar
SetElementsVisibility(false); // Initial unsichtbar
}
public void OnTouchStarted(HandTrackingInputEventData eventData)
{
SetTextVisibility(true); // Sichtbar machen
SetElementsVisibility(true); // Sichtbar machen
}
public void OnTouchCompleted(HandTrackingInputEventData eventData)
{
SetTextVisibility(false); // Wieder unsichtbar machen
SetElementsVisibility(false); // Wieder unsichtbar machen
}
public void OnTouchUpdated(HandTrackingInputEventData eventData) { }
void SetTextVisibility(bool isVisible)
void SetElementsVisibility(bool isVisible)
{
if (isVisible)
foreach (var element in uiElements)
{
textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, 1.0f); // Voll sichtbar
SetVisibilityRecursive(element, isVisible);
}
else
}
void SetVisibilityRecursive(GameObject obj, bool isVisible)
{
// TextMeshPro-Komponente
TextMeshPro textMeshPro = obj.GetComponent<TextMeshPro>();
if (textMeshPro != null)
{
textMeshPro.color = new Color(textMeshPro.color.r, textMeshPro.color.g, textMeshPro.color.b, isVisible ? 1.0f : 0.0f);
}
// Renderer-Komponente (fr andere visuelle Elemente)
Renderer renderer = obj.GetComponent<Renderer>();
if (renderer != null)
{
renderer.enabled = isVisible;
}
// Weitere UI-Komponenten
var graphic = obj.GetComponent<UnityEngine.UI.Graphic>();
if (graphic != null)
{
graphic.color = new Color(graphic.color.r, graphic.color.g, graphic.color.b, isVisible ? 1.0f : 0.0f);
}
// Rekursiv fr alle Kinderobjekte
foreach (Transform child in obj.transform)
{
textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, 0.0f); // Unsichtbar
SetVisibilityRecursive(child.gameObject, isVisible);
}
}
}
using Microsoft.MixedReality.Toolkit.Input;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Whiteboard : MonoBehaviour, IMixedRealityTouchHandler
{
public List<GameObject> uiElements; // Liste fr alle bergeordneten UI-Elemente (TextMeshPro und Buttons)
void Start()
{
SetElementsVisibility(false); // Initial unsichtbar
}
public void OnTouchStarted(HandTrackingInputEventData eventData)
{
SetElementsVisibility(true); // Sichtbar machen
}
public void OnTouchCompleted(HandTrackingInputEventData eventData)
{
SetElementsVisibility(false); // Wieder unsichtbar machen
}
public void OnTouchUpdated(HandTrackingInputEventData eventData) { }
void SetElementsVisibility(bool isVisible)
{
foreach (var element in uiElements)
{
SetVisibilityRecursive(element, isVisible);
}
}
void SetVisibilityRecursive(GameObject obj, bool isVisible)
{
// TextMeshPro-Komponente
TextMeshPro textMeshPro = obj.GetComponent<TextMeshPro>();
if (textMeshPro != null)
{
textMeshPro.color = new Color(textMeshPro.color.r, textMeshPro.color.g, textMeshPro.color.b, isVisible ? 1.0f : 0.0f);
}
// Renderer-Komponente (fr andere visuelle Elemente)
Renderer renderer = obj.GetComponent<Renderer>();
if (renderer != null)
{
renderer.enabled = isVisible;
}
// Weitere UI-Komponenten
var graphic = obj.GetComponent<UnityEngine.UI.Graphic>();
if (graphic != null)
{
graphic.color = new Color(graphic.color.r, graphic.color.g, graphic.color.b, isVisible ? 1.0f : 0.0f);
}
// Rekursiv fr alle Kinderobjekte
foreach (Transform child in obj.transform)
{
SetVisibilityRecursive(child.gameObject, isVisible);
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: ca82bdfff9752b645a53d7378d2ccfb7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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