From fcc9935325ff273b5af3f6441c39943b43bab663 Mon Sep 17 00:00:00 2001 From: PopSlime Date: Tue, 15 Nov 2022 12:10:54 +0800 Subject: [PATCH] Fix input config. --- Assets/Cryville/Crtr/InputProxy.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Assets/Cryville/Crtr/InputProxy.cs b/Assets/Cryville/Crtr/InputProxy.cs index dfb3eb7..81a1020 100644 --- a/Assets/Cryville/Crtr/InputProxy.cs +++ b/Assets/Cryville/Crtr/InputProxy.cs @@ -43,8 +43,10 @@ namespace Cryville.Crtr { if (_use[proxy.Target] > 0) throw new InvalidOperationException("Input already assigned"); if (proxy.Source != null) { - proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown - proxy.Source.Value.Handler.OnInput += OnInput; + if (_judge != null) { + proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown + proxy.Source.Value.Handler.OnInput += OnInput; + } _tproxies.Add(proxy.Target, proxy); _sproxies.Add(proxy.Source.Value, proxy); IncrementUseRecursive(name); @@ -53,7 +55,7 @@ namespace Cryville.Crtr { } void Remove(InputProxyEntry proxy) { var name = proxy.Target; - proxy.Source.Value.Handler.OnInput -= OnInput; + if (_judge != null) _tproxies[name].Source.Value.Handler.OnInput -= OnInput; _sproxies.Remove(_tproxies[name].Source.Value); _tproxies.Remove(name); DecrementUseRecursive(name);