chore: prevent calling things in editor mode

develop
CrackThrough 2022-11-08 15:57:40 +09:00
parent fd8171dd56
commit 3c29035c02
1 changed files with 19 additions and 0 deletions

View File

@ -41,12 +41,15 @@ namespace SkyHook
/// <summary> /// <summary>
/// The instance of <see cref="SkyHookManager"/>. /// The instance of <see cref="SkyHookManager"/>.
/// A new instance will be created if it does not exist. /// A new instance will be created if it does not exist.
/// <br/>
/// This will return <c>null</c> if <see cref="Application.isPlaying"/> is <c>false</c>.
/// </summary> /// </summary>
// ReSharper disable once MemberCanBePrivate.Global // ReSharper disable once MemberCanBePrivate.Global
public static SkyHookManager Instance public static SkyHookManager Instance
{ {
get get
{ {
if (!Application.isPlaying) return null;
if (_instance) return _instance; if (_instance) return _instance;
var obj = new GameObject("SkyHook Manager"); var obj = new GameObject("SkyHook Manager");
@ -119,17 +122,33 @@ namespace SkyHook
/// <summary> /// <summary>
/// Starts the native hook. /// Starts the native hook.
/// <br/>
/// This will only work if <see cref="Application.isPlaying"/> is <c>true</c>.
/// </summary> /// </summary>
public static void StartHook() public static void StartHook()
{ {
if (!Application.isPlaying)
{
Debug.LogWarning("You may not call StartHook() if the application is not playing.");
return;
}
Instance._StartHook(); Instance._StartHook();
} }
/// <summary> /// <summary>
/// Stops the native hook. /// Stops the native hook.
/// <br/>
/// This will only work if <see cref="Application.isPlaying"/> is <c>true</c>.
/// </summary> /// </summary>
public static void StopHook() public static void StopHook()
{ {
if (!Application.isPlaying)
{
Debug.LogWarning("You may not call StopHook() if the application is not playing.");
return;
}
Instance._StopHook(); Instance._StopHook();
} }