diff --git a/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs b/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs index 1b05236aa..28e9daf84 100644 --- a/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs +++ b/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs @@ -46,6 +46,13 @@ namespace Spine.Unity.Editor { private SerializedProperty atlasFile, materials; private AtlasAsset atlasAsset; + private List Regions { + get { + FieldInfo regionsField = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.NonPublic); + return (List)regionsField.GetValue(atlasAsset.GetAtlas()); + } + } + void OnEnable () { SpineEditorUtilities.ConfirmInitialization(); atlasFile = serializedObject.FindProperty("atlasFile"); @@ -57,13 +64,6 @@ namespace Spine.Unity.Editor { #endif } - private List Regions { - get { - FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.NonPublic); - return (List)field.GetValue(atlasAsset.GetAtlas()); - } - } - #if REGION_BAKING_MESH private List baked; private List bakedObjects; @@ -73,14 +73,10 @@ namespace Spine.Unity.Editor { baked = new List(); bakedObjects = new List(); if (atlasFile.objectReferenceValue != null) { - Atlas atlas = asset.GetAtlas(); - FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic); - List regions = (List)field.GetValue(atlas); + List regions = this.Regions; string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset); string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath); string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name); - - for (int i = 0; i < regions.Count; i++) { AtlasRegion region = regions[i]; string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");