|
@@ -1020,13 +1020,18 @@ namespace Spine.Unity.Editor {
|
|
pageFiles.Add(atlasLines[i + 1].Trim());
|
|
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++) {
|
|
for (int i = 0; i < pageFiles.Count; i++) {
|
|
string texturePath = assetPath + "/" + pageFiles[i];
|
|
string texturePath = assetPath + "/" + pageFiles[i];
|
|
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
|
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
|
|
|
|
|
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
|
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
|
|
#if UNITY_5_5_OR_NEWER
|
|
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
|
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
|
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
|
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
|
@@ -1039,7 +1044,6 @@ namespace Spine.Unity.Editor {
|
|
texImporter.spriteImportMode = SpriteImportMode.None;
|
|
texImporter.spriteImportMode = SpriteImportMode.None;
|
|
texImporter.maxTextureSize = 2048;
|
|
texImporter.maxTextureSize = 2048;
|
|
|
|
|
|
-
|
|
|
|
EditorUtility.SetDirty(texImporter);
|
|
EditorUtility.SetDirty(texImporter);
|
|
AssetDatabase.ImportAsset(texturePath);
|
|
AssetDatabase.ImportAsset(texturePath);
|
|
AssetDatabase.SaveAssets();
|
|
AssetDatabase.SaveAssets();
|
|
@@ -1064,9 +1068,11 @@ namespace Spine.Unity.Editor {
|
|
EditorUtility.SetDirty(mat);
|
|
EditorUtility.SetDirty(mat);
|
|
AssetDatabase.SaveAssets();
|
|
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++)
|
|
for (int i = 0; i < vestigialMaterials.Count; i++)
|
|
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i]));
|
|
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i]));
|
|
|
|
|
|
@@ -1078,6 +1084,11 @@ namespace Spine.Unity.Editor {
|
|
EditorUtility.SetDirty(atlasAsset);
|
|
EditorUtility.SetDirty(atlasAsset);
|
|
AssetDatabase.SaveAssets();
|
|
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.
|
|
// Iterate regions and bake marked.
|
|
Atlas atlas = atlasAsset.GetAtlas();
|
|
Atlas atlas = atlasAsset.GetAtlas();
|
|
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
|
|
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
|