AddDynamic is permanent!
I'm using UE 4.18. I find myself in this situation, in a constructor I have:
This is the ONLY place where the function OnCoverVolumeBeginOverlap is added to the delegate OnComponentBeginOverlap. It all works fine until I decided I don't need this binding. So what did I do? I removed this code from my constructor. Guess what? This thing doesn't go away. The function OnCoverVolumeBeginOverlap keeps getting called. I cleaned my solution, rebuild it several times, deleted the Binaries, Intermediate folders and it still persists. What is going on? This is driving me crazy. I'm absolutely sure this is the only place that this binding is happening. I tried calling OnComponentBeginOverlap.Clear(), still doesn't help. Anyone experienced such madness?
asked Jan 31 '18 at 01:33 PM in C++ Programming
Posting here for completion's sake:
I suspect what is happening is that a blueprint subclass of this class is causing the issue. Some UE4 delegates can be serialized (saved), and when you created the blueprint, the constructor created that delegate binding and serialized it to the saved blueprint asset.
If you change the constructor of a class in C++, there's no guarantee that those changes will propagate to existing blueprint assets you have created - so you will have to delete and re-create the blueprint from scratch. There isn't an easy solution to this problem in general, unfortunately.
In this particular case, you might be able to add a 'Clear' method to the constructor then open and re-save the blueprint asset.
Hope this helps!
answered Jan 31 '18 at 02:15 PM
Ehi dude, I know that some time has passed and you may have found a better solution, in any case I have found an easy and quick way to fix this problem: my the trick is to remove the bindings to the delegate in the BP "Event Graph", for example after the Beginplay or some other default or custom event. For example I have a custom userwidget which I've implemented in C++, delegates included. When I create the derived BP for design its widgets, I go to the Event Graph and from the "Pre-Construct" node I remove all the bindings to my delegate. This works fine and you don't need to delete and recreate the BP every time !
answered Jan 08 '19 at 09:08 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here