1010namespace UnityCustomTextureRenderer
1111{
1212 /// <summary>
13- /// A graphics utility to update textures from native plugins.
14- /// The function for updating textures runs on Unity's Render Thread.
13+ /// A graphics utility to update textures from native plugins. <br/>
14+ /// The function for updating textures runs on Unity's Render Thread. <br/>
1515 /// </summary>
1616 public sealed class CustomTextureRenderer : IDisposable
1717 {
1818 UpdateRawTextureDataFunction _updateRawTextureDataFunction ;
1919
2020 Texture2D _targetTexture ;
21- int _textureWidth ;
22- int _textureHeight ;
23- int _bytesPerPixel ;
21+ readonly int _textureWidth ;
22+ readonly int _textureHeight ;
23+ readonly int _bytesPerPixel ;
2424
2525 bool _disposed ;
2626
@@ -44,10 +44,8 @@ public sealed class CustomTextureRenderer : IDisposable
4444 /// </summary>
4545 /// <param name="updateRawTextureDataFunction"></param>
4646 /// <param name="targetTexture"></param>
47- /// <param name="bytesPerPixel"></param>
4847 /// <param name="autoDispose"></param>
49- public CustomTextureRenderer ( UpdateRawTextureDataFunction updateRawTextureDataFunction ,
50- Texture2D targetTexture , int bytesPerPixel = 4 , bool autoDispose = true )
48+ public CustomTextureRenderer ( UpdateRawTextureDataFunction updateRawTextureDataFunction , Texture2D targetTexture , bool autoDispose = true )
5149 {
5250#if DEVELOPMENT_BUILD || UNITY_EDITOR
5351 _updateRawTextureDataFunctionSampler = CustomSampler . Create ( "UpdateRawTextureDataFunction" ) ;
@@ -68,7 +66,7 @@ public CustomTextureRenderer(UpdateRawTextureDataFunction updateRawTextureDataFu
6866 _targetTexture = targetTexture ;
6967 _textureWidth = targetTexture . width ;
7068 _textureHeight = targetTexture . height ;
71- _bytesPerPixel = bytesPerPixel ;
69+ _bytesPerPixel = 4 ; // RGBA32. 1 byte (8 bits) per channel.
7270
7371 _buffer = new uint [ _targetTexture . width * _targetTexture . height ] ;
7472 _bufferHandle = GCHandle . Alloc ( _buffer , GCHandleType . Pinned ) ;
0 commit comments