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 6ddbdde84..a9f583af0 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 @@ -642,6 +642,7 @@ namespace Spine.Unity.Editor { } List populatingMaterials = new List(pageFiles.Count); + string materialDirectory = GetMaterialDirectory(assetPath, vestigialMaterials); for (int i = 0; i < pageFiles.Count; i++) { string texturePath = assetPath + "/" + pageFiles[i]; @@ -660,9 +661,8 @@ namespace Spine.Unity.Editor { if (pageName == primaryName && pageFiles.Count == 1) pageName = "Material"; - string materialPath = assetPath + "/" + primaryName + "_" + pageName + ".mat"; + string materialPath = materialDirectory + "/" + primaryName + "_" + pageName + ".mat"; Material material = (Material)AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)); - if (material == null) { Shader defaultShader = GetDefaultShader(); material = defaultShader != null ? new Material(defaultShader) : null; @@ -836,7 +836,6 @@ namespace Spine.Unity.Editor { string primaryName = spriteAtlas.name; string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spriteAtlas)).Replace('\\', '/'); - string atlasPath = assetPath + "/" + primaryName + SpriteAtlasSuffix + ".asset"; SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath(atlasPath); @@ -900,6 +899,15 @@ namespace Spine.Unity.Editor { return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase)); } + static string GetMaterialDirectory (string assetPath, List previousMaterials) { + if (previousMaterials.Count > 0 && previousMaterials[0] != null) { + string materialPath = AssetDatabase.GetAssetPath(previousMaterials[0]); + string materialDirectory = Path.GetDirectoryName(materialPath).Replace('\\', '/'); + return materialDirectory; + } + return assetPath; + } + static bool SetDefaultTextureSettings (string texturePath, SpineAtlasAsset atlasAsset) { TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath); if (texImporter == null) { diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index 1dbe46b10..edc054335 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -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.2.73", + "version": "4.2.74", "unity": "2018.3", "author": { "name": "Esoteric Software",