|
@@ -575,22 +575,23 @@ namespace Spine.Unity.Editor {
|
|
pageName = "Material";
|
|
pageName = "Material";
|
|
|
|
|
|
string materialPath = assetPath + "/" + primaryName + "_" + pageName + ".mat";
|
|
string materialPath = assetPath + "/" + primaryName + "_" + pageName + ".mat";
|
|
- Material mat = (Material)AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material));
|
|
|
|
|
|
+ Material material = (Material)AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material));
|
|
|
|
|
|
- if (mat == null) {
|
|
|
|
- mat = new Material(Shader.Find(SpineEditorUtilities.Preferences.defaultShader));
|
|
|
|
- ApplyPMAOrStraightAlphaSettings(mat, SpineEditorUtilities.Preferences.textureSettingsReference);
|
|
|
|
- AssetDatabase.CreateAsset(mat, materialPath);
|
|
|
|
|
|
+ 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);
|
|
} else {
|
|
} else {
|
|
- vestigialMaterials.Remove(mat);
|
|
|
|
|
|
+ vestigialMaterials.Remove(material);
|
|
}
|
|
}
|
|
|
|
|
|
if (texture != null)
|
|
if (texture != null)
|
|
- mat.mainTexture = texture;
|
|
|
|
|
|
+ material.mainTexture = texture;
|
|
|
|
|
|
- EditorUtility.SetDirty(mat);
|
|
|
|
|
|
+ EditorUtility.SetDirty(material);
|
|
// note: don't call AssetDatabase.SaveAssets() since this would trigger OnPostprocessAllAssets() every time unnecessarily.
|
|
// note: don't call AssetDatabase.SaveAssets() since this would trigger OnPostprocessAllAssets() every time unnecessarily.
|
|
- populatingMaterials.Add(mat); //atlasAsset.materials[i] = mat;
|
|
|
|
|
|
+ populatingMaterials.Add(material); //atlasAsset.materials[i] = mat;
|
|
}
|
|
}
|
|
|
|
|
|
atlasAsset.materials = populatingMaterials.ToArray();
|
|
atlasAsset.materials = populatingMaterials.ToArray();
|