From 1f51b65be22ed5a32c25d7442af4fd95120f7bd8 Mon Sep 17 00:00:00 2001 From: Tom Greener Date: Fri, 7 May 2021 16:49:21 +0100 Subject: [PATCH] bug fix for unity single persistant when using on editor scripts --- Assets/Singletons/UnitySingletonPersistent.cs | 2 +- Assets/Singletons/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Singletons/UnitySingletonPersistent.cs b/Assets/Singletons/UnitySingletonPersistent.cs index e73dec8..f532354 100644 --- a/Assets/Singletons/UnitySingletonPersistent.cs +++ b/Assets/Singletons/UnitySingletonPersistent.cs @@ -41,7 +41,7 @@ public static void ValidateInstance(bool createIfNeeded = false) _instance = obj.AddComponent(); } - if (_instance != null) + if (_instance != null && Application.isPlaying) { Helpers.RegisterDontDestroy(_instance.gameObject); DontDestroyOnLoad(_instance); diff --git a/Assets/Singletons/package.json b/Assets/Singletons/package.json index f1a102a..25b5cae 100644 --- a/Assets/Singletons/package.json +++ b/Assets/Singletons/package.json @@ -2,7 +2,7 @@ "name": "com.greener-games.singletons", "displayName": "Unity singleton", "description": "Collection of Singleton for use in unity", - "version": "1.0.3", + "version": "1.0.4", "unity": "2018.1", "license": "MIT", "author": {