mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] Fixed Materials in separate directory being deleted upon reimport. Closes #2560.
This commit is contained in:
parent
24070b4768
commit
6df18e22d3
@ -642,6 +642,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
List<Material> populatingMaterials = new List<Material>(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<SpineSpriteAtlasAsset>(atlasPath);
|
||||
@ -900,6 +899,15 @@ namespace Spine.Unity.Editor {
|
||||
return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase));
|
||||
}
|
||||
|
||||
static string GetMaterialDirectory (string assetPath, List<Material> 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) {
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user