Skip to content

Commit 49bd0b0

Browse files
committed
Update sample scene
1 parent ae1815b commit 49bd0b0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Assets/CustomTextureRenderer.Samples/Scripts/Test.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ namespace UnityCustomTextureRenderer.Samples
66
{
77
public class Test : MonoBehaviour
88
{
9+
#if PLATFORM_IOS
10+
[System.Runtime.InteropServices.DllImport("__Internal")]
11+
#else
12+
[System.Runtime.InteropServices.DllImport("Plasma")]
13+
#endif
14+
static extern IntPtr GetTextureUpdateCallback();
15+
916
[System.Runtime.InteropServices.DllImport("Plasma2")]
1017
static extern IntPtr UpdateRawTextureData(IntPtr data, int width, int height, uint frameCount);
1118

@@ -20,7 +27,15 @@ enum TextureSize
2027
_4096x4096,
2128
}
2229

30+
enum PluginType
31+
{
32+
Type1,
33+
Type2
34+
}
35+
2336
[SerializeField] TextureSize _textureSize;
37+
[SerializeField] PluginType _pluginType;
38+
2439
public event Action<(int TextureWidth, int TextureHeight)> OnInitialized;
2540

2641
uint _frame;
@@ -45,8 +60,17 @@ void Start()
4560
_texture = new Texture2D(size, size, TextureFormat.RGBA32, false);
4661
_texture.wrapMode = TextureWrapMode.Clamp;
4762

48-
_pluginTextureRenderer = new PluginTextureRenderer(UpdateRawTextureDataCallback, _texture);
49-
CustomTextureRenderSystem.Instance.AddRenderer(_pluginTextureRenderer);
63+
if (_pluginType is PluginType.Type1)
64+
{
65+
var callback = Marshal.GetDelegateForFunctionPointer<IssuePluginCustomTextureUpdateCallback>(GetTextureUpdateCallback());
66+
_pluginTextureRenderer = new PluginTextureRenderer(callback, _texture);
67+
CustomTextureRenderSystem.Instance.AddRenderer(_pluginTextureRenderer);
68+
}
69+
else if (_pluginType is PluginType.Type2)
70+
{
71+
_pluginTextureRenderer = new PluginTextureRenderer(UpdateRawTextureDataCallback, _texture);
72+
CustomTextureRenderSystem.Instance.AddRenderer(_pluginTextureRenderer);
73+
}
5074

5175
// Set the texture to the renderer with using a property block.
5276
var prop = new MaterialPropertyBlock();

Assets/CustomTextureRenderer.Samples/Test.unity

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ MonoBehaviour:
955955
m_Name:
956956
m_EditorClassIdentifier:
957957
_textureSize: 3
958+
_pluginType: 0
958959
--- !u!1 &1703854062
959960
GameObject:
960961
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)