From 6fc6e090ae22cc04226cd8a20487f0f6ab42dba1 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 24 May 2022 16:31:58 +0200 Subject: [PATCH] [unity] Fixed rare import error that material.mainTexture is null ("Material is missing texture"). --- .../Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 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 d1ae05371..bbf9d6f3d 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 @@ -582,6 +582,8 @@ namespace Spine.Unity.Editor { material = defaultShader != null ? new Material(defaultShader) : null; if (material) { ApplyPMAOrStraightAlphaSettings(material, SpineEditorUtilities.Preferences.textureSettingsReference); + if (texture != null) + material.mainTexture = texture; AssetDatabase.CreateAsset(material, materialPath); } } else { @@ -589,10 +591,8 @@ namespace Spine.Unity.Editor { } if (material != null) { - if (texture != 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;