From dd80f238b7ea0b7966ec08adde568551c7c4f996 Mon Sep 17 00:00:00 2001 From: ssootube <58128848+ssootube@users.noreply.github.com> Date: Sun, 17 Jan 2021 03:59:53 +0900 Subject: [PATCH] fix Duplicated GameObject Problem --- UnityMainThreadDispatcher.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UnityMainThreadDispatcher.cs b/UnityMainThreadDispatcher.cs index 7a4f783..0a582cf 100644 --- a/UnityMainThreadDispatcher.cs +++ b/UnityMainThreadDispatcher.cs @@ -109,10 +109,15 @@ void Awake() { _instance = this; DontDestroyOnLoad(this.gameObject); } + else if(this != _instance) { + Destroy(this); + } } void OnDestroy() { + if(this == _instance) { _instance = null; + } }