Skip to content

Commit f6cc5a0

Browse files
author
david.algis
committed
♻️ Now monobehavior event are called from InteropHandlerSample and not for InteropHandler to improve flexibility
1 parent 7f87ef7 commit f6cc5a0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

InteropUnityCUDA/Assets/Actions/InteropHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public abstract class InteropHandler : MonoBehaviour
4040

4141
protected virtual int ReserveCapacity => 16;
4242

43-
protected void Start()
43+
public void InitializeInteropHandler()
4444
{
4545
// initialize log
4646
StartLog();
@@ -58,7 +58,7 @@ protected virtual void InitializeActions()
5858
{
5959
}
6060

61-
protected void Update()
61+
public void UpdateInteropHandler()
6262
{
6363
//to update the time used in InteropDll
6464
SetTime(Time.time);
@@ -73,7 +73,7 @@ protected virtual void UpdateActions()
7373
{
7474
}
7575

76-
protected void OnDestroy()
76+
public void OnDestroyInteropHandler()
7777
{
7878
OnDestroyActions();
7979
}

InteropUnityCUDA/Assets/Actions/InteropHandlerSample.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Runtime.InteropServices;
23
using Unity.Mathematics;
34
using UnityEngine;
@@ -108,6 +109,11 @@ private void CreateBuffer()
108109
_particlesDrawer.InitParticlesBuffer(_computeBuffer, _sizeBuffer, 0.1f);
109110
}
110111

112+
private void Start()
113+
{
114+
InitializeInteropHandler();
115+
}
116+
111117
/// <summary>
112118
/// Create the texture and the buffer. Construct action from them. Register these action in InteropUnityCUDA and
113119
/// call start function on it
@@ -136,6 +142,10 @@ protected override void InitializeActions()
136142
CallFunctionStartInAction(_ActionTextureArrayName);
137143
}
138144

145+
public void Update()
146+
{
147+
UpdateInteropHandler();
148+
}
139149

140150
/// <summary>
141151
/// call update function of the two registered actions
@@ -152,6 +162,11 @@ protected override void UpdateActions()
152162
_rawImageTextureArray1.texture = _renderTextureForDisplay1;
153163
}
154164

165+
public void OnDestroy()
166+
{
167+
OnDestroyInteropHandler();
168+
}
169+
155170
/// <summary>
156171
/// call onDestroy function of the two registered actions
157172
/// </summary>

0 commit comments

Comments
 (0)