This commit is contained in:
Mario Zechner 2023-06-27 15:11:10 +02:00
commit 0f118ba3bd
2 changed files with 19 additions and 12 deletions

View File

@ -664,7 +664,7 @@ namespace Spine.Unity.Editor {
Material material = (Material)AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material));
if (material == null) {
Shader defaultShader = Shader.Find(SpineEditorUtilities.Preferences.DefaultShader);
Shader defaultShader = GetDefaultShader();
material = defaultShader != null ? new Material(defaultShader) : null;
if (material) {
ApplyPMAOrStraightAlphaSettings(material, SpineEditorUtilities.Preferences.textureSettingsReference);
@ -737,6 +737,13 @@ namespace Spine.Unity.Editor {
return loadedAtlas != null ? loadedAtlas : atlasAsset;
}
public static Shader GetDefaultShader () {
Shader shader = Shader.Find(SpineEditorUtilities.Preferences.DefaultShader);
if (shader == null) shader = Shader.Find("Spine/Skeleton");
if (shader == null) shader = Shader.Find("Standard");
return shader;
}
public static bool SpriteAtlasSettingsNeedAdjustment (UnityEngine.U2D.SpriteAtlas spriteAtlas) {
#if EXPOSES_SPRITE_ATLAS_UTILITIES
UnityEditor.U2D.SpriteAtlasPackingSettings packingSettings = UnityEditor.U2D.SpriteAtlasExtensions.GetPackingSettings(spriteAtlas);
@ -851,24 +858,24 @@ namespace Spine.Unity.Editor {
{
string pageName = "SpriteAtlas";
string materialPath = assetPath + "/" + primaryName + "_" + pageName + ".mat";
Material mat = AssetDatabase.LoadAssetAtPath<Material>(materialPath);
Material material = AssetDatabase.LoadAssetAtPath<Material>(materialPath);
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 = GetDefaultShader();
material = defaultShader != null ? new Material(defaultShader) : null;
ApplyPMAOrStraightAlphaSettings(material, SpineEditorUtilities.Preferences.textureSettingsReference);
AssetDatabase.CreateAsset(material, materialPath);
} else {
vestigialMaterials.Remove(mat);
vestigialMaterials.Remove(material);
}
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.
populatingMaterials.Add(mat); //atlasAsset.materials[i] = mat;
populatingMaterials.Add(material);
}
atlasAsset.materials = populatingMaterials.ToArray();

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.",
"version": "4.1.14",
"version": "4.1.15",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",