66using UnityEngine ;
77using UnityEngine . UI ;
88
9+ using CommandBuffer = UnityEngine . Rendering . CommandBuffer ;
10+
911namespace OpenTibiaUnity . Modules . Outfit
1012{
1113 public class OutfitWindow : Core . Components . Base . Window
@@ -120,8 +122,9 @@ protected void OnGUI() {
120122 _rawImageMount . texture = _renderTexture ;
121123 }
122124
123- RenderTexture . active = _renderTexture ;
124- Core . Utils . GraphicsUtility . ClearWithTransparency ( ) ;
125+ var commandBuffer = new CommandBuffer ( ) ;
126+ commandBuffer . SetRenderTarget ( _renderTexture ) ;
127+ commandBuffer . ClearRenderTarget ( false , true , Core . Utils . GraphicsUtility . TransparentColor ) ;
125128
126129 if ( ! ! _currentOutfit ) {
127130 var screenPosition = new Vector2Int ( Constants . FieldSize , Constants . FieldSize ) ;
@@ -133,9 +136,9 @@ protected void OnGUI() {
133136 }
134137
135138 if ( _currentOutfit is OutfitInstance )
136- _currentOutfit . Draw ( screenPosition , zoom , ( int ) _currentDirection , 0 , 0 ) ;
139+ _currentOutfit . Draw ( commandBuffer , screenPosition , zoom , ( int ) _currentDirection , 0 , 0 ) ;
137140 else
138- _currentOutfit . Draw ( screenPosition , zoom , 0 , 0 , 0 ) ;
141+ _currentOutfit . Draw ( commandBuffer , screenPosition , zoom , 0 , 0 , 0 ) ;
139142
140143 if ( ! _rawImageOutfit . enabled )
141144 _rawImageOutfit . enabled = true ;
@@ -149,15 +152,16 @@ protected void OnGUI() {
149152 screenPosition += new Vector2Int ( Constants . FieldSize * 2 , 0 ) ;
150153
151154 if ( _currentMount is OutfitInstance )
152- _currentMount . Draw ( screenPosition , zoom , ( int ) _currentDirection , 0 , 0 ) ;
155+ _currentMount . Draw ( commandBuffer , screenPosition , zoom , ( int ) _currentDirection , 0 , 0 ) ;
153156 else
154- _currentMount . Draw ( screenPosition , zoom , 0 , 0 , 0 ) ;
157+ _currentMount . Draw ( commandBuffer , screenPosition , zoom , 0 , 0 , 0 ) ;
155158
156159 if ( ! _rawImageMount . enabled )
157160 _rawImageMount . enabled = true ;
158161 }
159162
160- RenderTexture . active = null ;
163+ Graphics . ExecuteCommandBuffer ( commandBuffer ) ;
164+ commandBuffer . Dispose ( ) ;
161165 }
162166
163167 protected override void OnEnable ( ) {
0 commit comments