MixedRealityToolkit-Unity: Sync System: root object added listener does not raise events properly
I’m just having trouble getting a listener on the root object to raise events properly.
RootSyncObject = SharingStage.Instance.Manager.GetRootSyncObject();
objElementAdapter = new ObjectElementAdapter();
objElementAdapter.ElementAddedEvent += OnElementAdded;
objElementAdapter.ElementDeletedEvent += OnElementDeleted;
RootSyncObject.AddListener(objElementAdapter);
I’m getting the root object and adding a listener but that listener never raises ElementAddedEvent nor ElementDeletedEvent.
Here’s the branch I’ve set up for proper testing: https://github.com/HodgsonSDAS/HoloToolkit-Unity/tree/SyncSystemTests
- Open
SyncSystemTests.unity - Add breakpoints to
ObjectElementAdapter.cslines 34, 123, & 137. - Start Debugging in visual studio and attach to Unity Editor.
- Run the
SyncSystemTest.unityscene. - Create/Delete object object and int elements.
- Increment and decrement int value.
- Observe events not raised.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (16 by maintainers)
Oh, local changes do not raise events on the local client. Events only get raised by remote client changes. You need to keep any local modifications done to intValueText.text.
D’oh, looks like it was. Pull request makes much more sense! Done. You should see the add/delete event for ObjectElements too, but I didn’t test that. Only investigated the IntElement for you.
Note that for every ObjectElement you need to AddListener to receive that ObjectElement’s events. The change events don’t propagate up to the root.
I can confirm that events are firing properly. I just had an initialization issue within my project. Fixing that cause all the handlers to execute correctly. I’m going to compare the setup of my project with what you’ve created to see where we differ.