From d15b55745d50153b2f8fbce19d34c6910ff8366a Mon Sep 17 00:00:00 2001 From: Thor Kramer Brigsted Date: Wed, 29 Nov 2017 09:16:48 +0100 Subject: [PATCH] Null check changes --- Scripts/Editor/NodeEditorPreferences.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index 3424462..002f0d4 100644 --- a/Scripts/Editor/NodeEditorPreferences.cs +++ b/Scripts/Editor/NodeEditorPreferences.cs @@ -6,9 +6,21 @@ using UnityEngine; namespace XNodeEditor { public static class NodeEditorPreferences { - public static Texture2D gridTexture { get { VerifyLoaded(); return _gridTexture; } } + public static Texture2D gridTexture { + get { + VerifyLoaded(); + if (_gridTexture == null) _gridTexture = NodeEditorResources.GenerateGridTexture(_gridLineColor, _gridBgColor); + return _gridTexture; + } + } private static Texture2D _gridTexture; - public static Texture2D crossTexture { get { VerifyLoaded(); return _crossTexture; } } + public static Texture2D crossTexture { + get { + VerifyLoaded(); + if (_crossTexture == null) _crossTexture = NodeEditorResources.GenerateCrossTexture(_gridLineColor); + return _crossTexture; + } + } private static Texture2D _crossTexture; /// Have we loaded the prefs yet @@ -121,8 +133,6 @@ namespace XNodeEditor { //Load snap option if (EditorPrefs.HasKey("unec_gridsnap")) _gridSnap = EditorPrefs.GetBool("unec_gridsnap"); - _gridTexture = NodeEditorResources.GenerateGridTexture(_gridLineColor, _gridBgColor); - _crossTexture = NodeEditorResources.GenerateCrossTexture(_gridLineColor); NodeEditorWindow.RepaintAll(); prefsLoaded = true; }