@@ -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 ( ) ;
0 commit comments