Skip to content

Commit ff4a3e2

Browse files
committed
Update
1 parent e05f6c6 commit ff4a3e2

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

Assets/CustomTextureRenderer.Samples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jp.sotanmochi.unitycustomtexturerenderer.samples",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"displayName": "CustomTextureRenderer.Samples",
55
"description": "A graphics utility to update textures from native plugins.",
66
"license": "MIT",

Assets/CustomTextureRenderer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The function for updating textures runs on another thread.
1414
// manifest.json
1515
{
1616
"dependencies": {
17-
"jp.sotanmochi.unitycustomtexturerenderer": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer#v1.3.0 ",
18-
"jp.sotanmochi.unitycustomtexturerenderer.samples": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer.Samples#v1.3.0",
17+
"jp.sotanmochi.unitycustomtexturerenderer": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer#v1.3.1 ",
18+
"jp.sotanmochi.unitycustomtexturerenderer.samples": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer.Samples#v1.3.1",
1919
...
2020
}
2121
}

Assets/CustomTextureRenderer/Runtime/PluginTextureRenderer.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public sealed class PluginTextureRenderer : IDisposable
1919
public Texture TargetTexture => _targetTexture;
2020
private Texture2D _targetTexture;
2121

22+
public int TextureBufferSize => (_textureBuffer is null) ? -1 : _textureBuffer.Length;
23+
2224
public bool Disposed => _disposed;
2325
private bool _disposed;
2426

@@ -48,7 +50,8 @@ public sealed class PluginTextureRenderer : IDisposable
4850
private CustomSampler _textureUpdateLoopSampler;
4951
#endif
5052

51-
public PluginTextureRenderer(RawTextureDataUpdateCallback callback, int textureWidth, int textureHeight,
53+
public PluginTextureRenderer(RawTextureDataUpdateCallback callback,
54+
int textureWidth, int textureHeight, int bufferSize = 0,
5255
int targetFrameRateOfPluginRenderThread = 60, bool autoDispose = true)
5356
{
5457
#if DEVELOPMENT_BUILD || UNITY_EDITOR
@@ -59,7 +62,7 @@ public PluginTextureRenderer(RawTextureDataUpdateCallback callback, int textureW
5962
_rawTextureDataUpdateCallback = callback;
6063
DebugLog($"[{nameof(PluginTextureRenderer)}] The RawTextureDataUpdateCallback is \n'{_rawTextureDataUpdateCallback.Target}.{_rawTextureDataUpdateCallback.Method.Name}'.");
6164

62-
CreateTextureBuffer(textureWidth, textureHeight);
65+
CreateTextureBuffer(textureWidth, textureHeight, bufferSize);
6366

6467
if (autoDispose){ UnityEngine.Application.quitting += Dispose; }
6568

@@ -132,7 +135,7 @@ public void Dispose()
132135
/// <param name="width"></param>
133136
/// <param name="height"></param>
134137
/// <returns></returns>
135-
public IntPtr CreateTextureBuffer(int width, int height)
138+
public IntPtr CreateTextureBuffer(int width, int height, int bufferSize = 0)
136139
{
137140
_updated = false;
138141

@@ -153,7 +156,15 @@ public IntPtr CreateTextureBuffer(int width, int height)
153156

154157
if (_rawTextureDataUpdateCallback != null)
155158
{
156-
_textureBuffer = new uint[_targetTexture.width * _targetTexture.height];
159+
if (bufferSize > _targetTexture.width * _targetTexture.height)
160+
{
161+
_textureBuffer = new uint[bufferSize];
162+
}
163+
else
164+
{
165+
_textureBuffer = new uint[_targetTexture.width * _targetTexture.height];
166+
}
167+
157168
_textureBufferHandle = GCHandle.Alloc(_textureBuffer, GCHandleType.Pinned);
158169
_textureBufferPtr = _textureBufferHandle.AddrOfPinnedObject();
159170
}

Assets/CustomTextureRenderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jp.sotanmochi.unitycustomtexturerenderer",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"displayName": "CustomTextureRenderer",
55
"description": "A graphics utility to update textures from native plugins.",
66
"license": "MIT",

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The function for updating textures runs on another thread.
1414
// manifest.json
1515
{
1616
"dependencies": {
17-
"jp.sotanmochi.unitycustomtexturerenderer": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer#v1.3.0",
18-
"jp.sotanmochi.unitycustomtexturerenderer.samples": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer.Samples#v1.3.0",
17+
"jp.sotanmochi.unitycustomtexturerenderer": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer#v1.3.1",
18+
"jp.sotanmochi.unitycustomtexturerenderer.samples": "https://github.com/sotanmochi/UnityCustomTextureRenderer.git?path=Assets/CustomTextureRenderer.Samples#v1.3.1",
1919
...
2020
}
2121
}

0 commit comments

Comments
 (0)