From 8338a63886de8850d7c26bb59ffb88d03fe19fe1 Mon Sep 17 00:00:00 2001
From: databasedav <31483365+databasedav@users.noreply.github.com>
Date: Mon, 26 Aug 2024 02:39:30 -0700
Subject: [PATCH] add disabling resource (#156)

---
 src/cursor.rs | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/cursor.rs b/src/cursor.rs
index f54fef6..27354b7 100644
--- a/src/cursor.rs
+++ b/src/cursor.rs
@@ -10,11 +10,20 @@ pub struct CursorSet;
 
 pub struct CursorPlugin;
 
+/// Unit resource whose existence in the world disables the cursor plugin systems.
+#[derive(Resource)]
+pub struct CursorPluginDisabled;
+
 impl Plugin for CursorPlugin {
     fn build(&self, app: &mut App) {
-        app.add_systems(Update, ((hover_sprites, hover_ui), change_cursor).chain())
-            .add_event::<TextHoverIn>()
-            .add_event::<TextHoverOut>();
+        app.add_systems(
+            Update,
+            ((hover_sprites, hover_ui), change_cursor)
+                .chain()
+                .run_if(not(resource_exists::<CursorPluginDisabled>)),
+        )
+        .add_event::<TextHoverIn>()
+        .add_event::<TextHoverOut>();
     }
 }
 
-- 
GitLab