浏览代码

[unity] Added additional null checks (unlikely to trigger, but added for sake of correctness).

Harald Csaszar 3 年之前
父节点
当前提交
362a9fcd20
共有 1 个文件被更改,包括 12 次插入7 次删除
  1. 12 7
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs

+ 12 - 7
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();