@@ -47,8 +47,8 @@ protected void OnGUI() {
4747
4848 Vector2 zoom = new Vector2 ( Screen . width / ( float ) _slotsRenderTexture . width , Screen . height / ( float ) _slotsRenderTexture . height ) ;
4949
50- _slotsRenderTexture . Release ( ) ;
5150 RenderTexture . active = _slotsRenderTexture ;
51+ Core . Utils . GraphicsUtility . ClearWithTransparency ( ) ;
5252 for ( int i = 0 ; i < 4 ; i ++ ) {
5353 for ( int j = 0 ; j < _rows ; j ++ ) {
5454 int index = j * 4 + i ;
@@ -69,6 +69,15 @@ protected void OnGUI() {
6969 RenderTexture . active = null ;
7070 }
7171
72+ protected override void OnDestroy ( ) {
73+ base . OnDestroy ( ) ;
74+
75+ if ( _slotsRenderTexture != null ) {
76+ _slotsRenderTexture . Release ( ) ;
77+ _slotsRenderTexture = null ;
78+ }
79+ }
80+
7281 protected void OnMouseUp ( Event e , MouseButton mouseButton , bool repeat ) {
7382 if ( publicStartMouseAction ( e . mousePosition , mouseButton , true , false ) )
7483 e . Use ( ) ;
@@ -212,15 +221,22 @@ public void UpdateProperties(ContainerView containerView) {
212221 _itemViews = null ;
213222 }
214223
224+ _numberOfSlots = containerView . NumberOfSlotsPerPage ;
225+ _rows = ( int ) Mathf . Ceil ( ( _numberOfSlots + 1 ) / 4f ) ; // extra slot for the container's icon
226+
227+ bool shouldCreateRenderTexture = true ;
215228 if ( _slotsRenderTexture != null ) {
216- _slotsRenderTexture . Release ( ) ;
217- _slotsRenderTexture . DiscardContents ( ) ;
218- _slotsRenderTexture = null ;
229+ if ( _slotsRenderTexture . height == Constants . FieldSize * _rows ) {
230+ shouldCreateRenderTexture = false ;
231+ } else {
232+ _slotsRenderTexture . Release ( ) ;
233+ _slotsRenderTexture = null ;
234+ }
219235 }
220236
221- _numberOfSlots = containerView . NumberOfSlotsPerPage ;
222- _rows = ( int ) Mathf . Ceil ( ( _numberOfSlots + 1 ) / 4f ) ; // extra slot for the container's icon
223- _slotsRenderTexture = new RenderTexture ( Constants . FieldSize * 4 , Constants . FieldSize * _rows , 0 , RenderTextureFormat . ARGB32 ) ;
237+ if ( shouldCreateRenderTexture )
238+ _slotsRenderTexture = new RenderTexture ( Constants . FieldSize * 4 , Constants . FieldSize * _rows , 0 , RenderTextureFormat . ARGB32 ) ;
239+
224240 _itemViews = new ItemView [ _numberOfSlots ] ;
225241 _containerView = containerView ;
226242
0 commit comments