From 3e3fc74c1f543b4f7c33c72bfe28ff16e7c5a010 Mon Sep 17 00:00:00 2001
From: Victor Victor <victor.victor@tu-dresden.de>
Date: Mon, 30 Jun 2025 01:47:49 +0200
Subject: [PATCH] Add `DebugLog` utility based on custom scripting symbols

---
 CHANGELOG.md                     |  6 ++++
 README.md                        | 10 +++++--
 Runtime/Scripts/DebugLog.cs      | 34 +++++++++++++++++++++++
 Runtime/Scripts/DebugLog.cs.meta |  2 ++
 Runtime/Scripts/TagsUnselect.cs  | 47 ++++++++++++++++++--------------
 package.json                     |  2 +-
 6 files changed, 78 insertions(+), 23 deletions(-)
 create mode 100644 Runtime/Scripts/DebugLog.cs
 create mode 100644 Runtime/Scripts/DebugLog.cs.meta

diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6a52c4..f4abe46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## 1.0.7 - 2025-06-30
+
+### Added
+
+- Add `DebugLog` utility based on custom scripting symbols.
+
 ## 1.0.6 - 2025-06-24
 
 ### Changed
diff --git a/README.md b/README.md
index 02fed97..156aaa0 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,9 @@ Please follow [this snippet] to add the registry to your project.
 
 [this snippet]: https://git-st.inf.tu-dresden.de/hyper/core/-/snippets/14
 
-## Quick start guide
+## How to use
+
+### Quick start guide
 
 1. Create a new Unity project with **Universal 3D** as the template.
 1. Switch the build target platform to **Android**.
@@ -32,9 +34,13 @@ Please follow [this snippet] to add the registry to your project.
 1. Right click on the **Hierarchy** panel, then click **HYPER** > **Core** > **XR**.
 1. Open **Meta** > **Tools** > **Project Setup Tool**, then click **Fix All** in all tabs.
 
-[Install this package]: https://git-st.inf.tu-dresden.de/hyper/core/-/snippets/14
+### Enable debug messages
+
+Add `HYPER_CORE_DEBUG_LOG` to **Project Settings** > **Player** > **Script Compilation** > **Scripting Define Symbols**.
 
 ## Attribution
 
 - Error.wav by Autistic Lucario -- https://freesound.org/s/142608/ -- License: Attribution 4.0
 - Ping! by unfa -- https://freesound.org/s/215415/ -- License: Creative Commons 0
+
+[Install this package]: https://git-st.inf.tu-dresden.de/hyper/core/-/snippets/14
diff --git a/Runtime/Scripts/DebugLog.cs b/Runtime/Scripts/DebugLog.cs
new file mode 100644
index 0000000..0228625
--- /dev/null
+++ b/Runtime/Scripts/DebugLog.cs
@@ -0,0 +1,34 @@
+using Debug = UnityEngine.Debug;
+using System;
+using System.Diagnostics;
+using UnityEngine;
+
+namespace Hyper.Core
+{
+    /// <summary>
+    /// A utility class for logging debug messages.
+    /// To enable, add "HYPER_CORE_DEBUG_LOG"
+    /// to Project Settings > Player > Script Compilation > Scripting Define Symbols
+    /// </summary>
+    public static class DebugLog
+    {
+        [Conditional("HYPER_CORE_DEBUG_LOG")]
+        public static void Log(LogType mType, string message)
+        {
+            switch (mType)
+            {
+                case LogType.Error:
+                    Debug.LogError(message);
+                    break;
+                case LogType.Warning:
+                    Debug.LogWarning(message);
+                    break;
+                case LogType.Log:
+                    Debug.Log(message);
+                    break;
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(mType), mType, null);
+            }
+        }
+    }
+}
diff --git a/Runtime/Scripts/DebugLog.cs.meta b/Runtime/Scripts/DebugLog.cs.meta
new file mode 100644
index 0000000..ed321b7
--- /dev/null
+++ b/Runtime/Scripts/DebugLog.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: bce965a2554d74bffa9f3a4e4ec9e45d
\ No newline at end of file
diff --git a/Runtime/Scripts/TagsUnselect.cs b/Runtime/Scripts/TagsUnselect.cs
index ed82452..3ec6c05 100644
--- a/Runtime/Scripts/TagsUnselect.cs
+++ b/Runtime/Scripts/TagsUnselect.cs
@@ -2,31 +2,38 @@ using System.Linq;
 using Oculus.Interaction.HandGrab;
 using UnityEngine;
 
-public class TagsUnselect : MonoBehaviour
+namespace Hyper.Core
 {
-    [SerializeField] private HandGrabInteractor handGrabInteractorLeft;
-    [SerializeField] private HandGrabInteractor handGrabInteractorRight;
-    [SerializeField] private string[] tags;
-
-    public void UnselectRightHand()
+    public class TagsUnselect : MonoBehaviour
     {
-        if (!handGrabInteractorRight.HasSelectedInteractable) return;
+        [SerializeField] private HandGrabInteractor handGrabInteractorLeft;
+        [SerializeField] private HandGrabInteractor handGrabInteractorRight;
+        [SerializeField] private string[] tags;
 
-        if (tags.Contains(handGrabInteractorRight.SelectedInteractable.tag))
-            handGrabInteractorRight.Unselect();
-    }
+        public void UnselectRightHand()
+        {
+            DebugLog.Log(LogType.Log, "Unselecting right hand interactable");
 
-    public void UnselectLeftHand()
-    {
-        if (!handGrabInteractorLeft.HasSelectedInteractable) return;
+            if (!handGrabInteractorRight.HasSelectedInteractable) return;
 
-        if (tags.Contains(handGrabInteractorLeft.SelectedInteractable.tag))
-            handGrabInteractorLeft.Unselect();
-    }
+            if (tags.Contains(handGrabInteractorRight.SelectedInteractable.tag))
+                handGrabInteractorRight.Unselect();
+        }
 
-    public void UnselectBothHands()
-    {
-        UnselectLeftHand();
-        UnselectRightHand();
+        public void UnselectLeftHand()
+        {
+            DebugLog.Log(LogType.Log, "Unselecting left hand interactable");
+
+            if (!handGrabInteractorLeft.HasSelectedInteractable) return;
+
+            if (tags.Contains(handGrabInteractorLeft.SelectedInteractable.tag))
+                handGrabInteractorLeft.Unselect();
+        }
+
+        public void UnselectBothHands()
+        {
+            UnselectLeftHand();
+            UnselectRightHand();
+        }
     }
 }
diff --git a/package.json b/package.json
index 518b1b5..b5de213 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "de.tu-dresden.hyper.core",
-  "version": "1.0.6",
+  "version": "1.0.7",
   "displayName": "HYPER Core",
   "description": "This package helps you to get started quickly with your Unity XR projects.",
   "unity": "6000.0",
-- 
GitLab