mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Merge remote-tracking branch 'origin/3.6' into 3.6
This commit is contained in:
commit
3382894f71
@ -1020,13 +1020,18 @@ namespace Spine.Unity.Editor {
|
||||
pageFiles.Add(atlasLines[i + 1].Trim());
|
||||
}
|
||||
|
||||
atlasAsset.materials = new Material[pageFiles.Count];
|
||||
var populatingMaterials = new List<Material>(pageFiles.Count);//atlasAsset.materials = new Material[pageFiles.Count];
|
||||
|
||||
for (int i = 0; i < pageFiles.Count; i++) {
|
||||
string texturePath = assetPath + "/" + pageFiles[i];
|
||||
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
||||
|
||||
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||
if (texImporter == null) {
|
||||
Debug.LogWarning(string.Format("{0} ::: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
|
||||
continue;
|
||||
}
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
||||
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
||||
@ -1039,7 +1044,6 @@ namespace Spine.Unity.Editor {
|
||||
texImporter.spriteImportMode = SpriteImportMode.None;
|
||||
texImporter.maxTextureSize = 2048;
|
||||
|
||||
|
||||
EditorUtility.SetDirty(texImporter);
|
||||
AssetDatabase.ImportAsset(texturePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
@ -1064,9 +1068,11 @@ namespace Spine.Unity.Editor {
|
||||
EditorUtility.SetDirty(mat);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
atlasAsset.materials[i] = mat;
|
||||
populatingMaterials.Add(mat); //atlasAsset.materials[i] = mat;
|
||||
}
|
||||
|
||||
atlasAsset.materials = populatingMaterials.ToArray();
|
||||
|
||||
for (int i = 0; i < vestigialMaterials.Count; i++)
|
||||
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i]));
|
||||
|
||||
@ -1078,6 +1084,11 @@ namespace Spine.Unity.Editor {
|
||||
EditorUtility.SetDirty(atlasAsset);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
if (pageFiles.Count != atlasAsset.materials.Length)
|
||||
Debug.LogWarning(string.Format("{0} ::: Not all atlas pages were imported. If you rename your image files, please make sure you also edit the filenames specified in the atlas file.", atlasAsset.name));
|
||||
else
|
||||
Debug.Log(string.Format("{0} ::: Imported with {1} material", atlasAsset.name, atlasAsset.materials.Length));
|
||||
|
||||
// Iterate regions and bake marked.
|
||||
Atlas atlas = atlasAsset.GetAtlas();
|
||||
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user