Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into 4.1
  • Loading branch information
badlogic committed Jun 27, 2023
2 parents 8fb691c + f3379d4 commit 0f118ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Expand Up @@ -664,7 +664,7 @@ public class AtlasRequirementLoader : AttachmentLoader {
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);
Expand Down Expand Up @@ -737,6 +737,13 @@ public class AtlasRequirementLoader : AttachmentLoader {
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);
Expand Down Expand Up @@ -851,24 +858,24 @@ public class AtlasRequirementLoader : AttachmentLoader {

{
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();
Expand Down
2 changes: 1 addition & 1 deletion spine-unity/Assets/Spine/package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 0f118ba

Please sign in to comment.