From 3c29035c0254b440a7af4c6b51046b438b6889c2 Mon Sep 17 00:00:00 2001 From: CrackThrough Date: Tue, 8 Nov 2022 15:57:40 +0900 Subject: [PATCH] chore: prevent calling things in editor mode --- Runtime/SkyHookManager.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Runtime/SkyHookManager.cs b/Runtime/SkyHookManager.cs index c0b1f1d..73b6a18 100644 --- a/Runtime/SkyHookManager.cs +++ b/Runtime/SkyHookManager.cs @@ -41,12 +41,15 @@ namespace SkyHook /// /// The instance of . /// A new instance will be created if it does not exist. + ///
+ /// This will return null if is false. ///
// ReSharper disable once MemberCanBePrivate.Global public static SkyHookManager Instance { get { + if (!Application.isPlaying) return null; if (_instance) return _instance; var obj = new GameObject("SkyHook Manager"); @@ -119,17 +122,33 @@ namespace SkyHook /// /// Starts the native hook. + ///
+ /// This will only work if is true. ///
public static void StartHook() { + if (!Application.isPlaying) + { + Debug.LogWarning("You may not call StartHook() if the application is not playing."); + return; + } + Instance._StartHook(); } /// /// Stops the native hook. + ///
+ /// This will only work if is true. ///
public static void StopHook() { + if (!Application.isPlaying) + { + Debug.LogWarning("You may not call StopHook() if the application is not playing."); + return; + } + Instance._StopHook(); }