From 40ac185dc7a017d95771fe580c77eab20e663908 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Tue, 08 Apr 2025 17:36:08 +0000
Subject: [PATCH] #46 added interactables
---
Assets/Scripts/Interact/GenericUIInteractable.cs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/Assets/Scripts/Interact/GenericUIInteractable.cs b/Assets/Scripts/Interact/GenericUIInteractable.cs
new file mode 100644
index 0000000..d99145a
--- /dev/null
+++ b/Assets/Scripts/Interact/GenericUIInteractable.cs
@@ -0,0 +1,50 @@
+using UnityEngine;
+using UnityEngine.InputSystem.XR;
+
+public class GenericUIInteractable : Interactable
+{
+ [SerializeField] private GameObject targetUI;
+ [SerializeField] private string interactableType;
+ [SerializeField] private bool closeOtherUIs = true;
+
+ [SerializeField] private GameObject[] uisToClose;
+
+ public override void Interact()
+ {
+ // Call base interaction event
+ OnInteract.Invoke();
+
+ // Close other UIs if needed
+ if (closeOtherUIs)
+ {
+ foreach (var ui in uisToClose)
+ {
+ if (ui != null)
+ {
+ ui.SetActive(false);
+ }
+ }
+ }
+
+ // Show target UI
+ if (targetUI != null)
+ {
+ targetUI.SetActive(true);
+
+ // If there's a UI controller component, notify it of the interaction
+ UIController uiController = targetUI.GetComponent<UIController>();
+ if (uiController != null)
+ {
+ uiController.OnUIOpened(interactableType, gameObject);
+ }
+ }
+ }
+ private new void OnTriggerExit2D(Collider2D other)
+ {
+ if (targetUI != null)
+ {
+ targetUI.SetActive(false);
+ base.OnTriggerExit2D(other);
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.10.0