@@ -69,6 +69,7 @@ protected IEnumerator process() {
69
69
while ( mRectangles . Count > 0 ) {
70
70
71
71
mPacker = new RectanglePacker ( mTexture . width , mTexture . height , padding ) ;
72
+
72
73
for ( int i = 0 ; i < mRectangles . Count ; i ++ )
73
74
mPacker . insertRectangle ( ( int ) mRectangles [ i ] . width , ( int ) mRectangles [ i ] . height , i ) ;
74
75
@@ -80,7 +81,9 @@ protected IEnumerator process() {
80
81
IntegerRectangle rect = new IntegerRectangle ( ) ;
81
82
List < TextureAsset > textureAssets = new List < TextureAsset > ( ) ;
82
83
83
- List < Rect > rectGarbages = new List < Rect > ( ) ;
84
+ List < Rect > garbageRect = new List < Rect > ( ) ;
85
+ List < Texture2D > garabeTextures = new List < Texture2D > ( ) ;
86
+ List < string > garbageImages = new List < string > ( ) ;
84
87
85
88
for ( int j = 0 ; j < mPacker . rectangleCount ; j ++ ) {
86
89
@@ -99,17 +102,19 @@ protected IEnumerator process() {
99
102
100
103
textureAssets . Add ( texture ) ;
101
104
102
- rectGarbages . Add ( mRectangles [ index ] ) ;
105
+ garbageRect . Add ( mRectangles [ index ] ) ;
106
+ garabeTextures . Add ( textures [ index ] ) ;
107
+ garbageImages . Add ( images [ index ] ) ;
103
108
}
104
109
105
- foreach ( Rect rectGarbage in rectGarbages ) {
110
+ foreach ( Rect garbage in garbageRect )
111
+ mRectangles . Remove ( garbage ) ;
106
112
107
- int indexToDestroy = mRectangles . IndexOf ( rectGarbage ) ;
113
+ foreach ( Texture2D garbage in garabeTextures )
114
+ textures . Remove ( garbage ) ;
108
115
109
- mRectangles . RemoveAt ( indexToDestroy ) ;
110
- textures . RemoveAt ( indexToDestroy ) ;
111
- images . RemoveAt ( indexToDestroy ) ;
112
- }
116
+ foreach ( string garbage in garbageImages )
117
+ images . Remove ( garbage ) ;
113
118
114
119
mTexture . Apply ( ) ;
115
120
@@ -129,7 +134,6 @@ protected IEnumerator process() {
129
134
130
135
foreach ( TextureAsset textureAsset in textureAssets )
131
136
mSprites . Add ( textureAsset . name , Sprite . Create ( mTexture , new Rect ( textureAsset . x , textureAsset . y , textureAsset . width , textureAsset . height ) , Vector2 . zero ) ) ;
132
-
133
137
}
134
138
135
139
}
0 commit comments