From 362a9fcd209d26f27da5bb1128f0919661ce8814 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 5 May 2022 18:23:21 +0200 Subject: [PATCH] [unity] Added additional null checks (unlikely to trigger, but added for sake of correctness). --- .../Editor/Utility/AssetUtility.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index acd8eaa67..d1ae05371 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -580,18 +580,23 @@ namespace Spine.Unity.Editor { if (material == null) { Shader defaultShader = Shader.Find(SpineEditorUtilities.Preferences.DefaultShader); material = defaultShader != null ? new Material(defaultShader) : null; - ApplyPMAOrStraightAlphaSettings(material, SpineEditorUtilities.Preferences.textureSettingsReference); - AssetDatabase.CreateAsset(material, materialPath); + if (material) { + ApplyPMAOrStraightAlphaSettings(material, SpineEditorUtilities.Preferences.textureSettingsReference); + AssetDatabase.CreateAsset(material, materialPath); + } } else { vestigialMaterials.Remove(material); } - if (texture != null) - material.mainTexture = texture; + if (material != null) { + if (texture != null) { + material.mainTexture = texture; + } - EditorUtility.SetDirty(material); - // note: don't call AssetDatabase.SaveAssets() since this would trigger OnPostprocessAllAssets() every time unnecessarily. - populatingMaterials.Add(material); //atlasAsset.materials[i] = mat; + EditorUtility.SetDirty(material); + // note: don't call AssetDatabase.SaveAssets() since this would trigger OnPostprocessAllAssets() every time unnecessarily. + populatingMaterials.Add(material); //atlasAsset.materials[i] = mat; + } } atlasAsset.materials = populatingMaterials.ToArray();