Im sorry if the title is is a bit convoluted, and somewhat long.
Im marking the actual questions per se in bold, though I think their context is necessary.
I’ve been messing around with the rendermaterials and been trying for them to generate some custom info, in an external container, that was supposed to be deleted when the material is deleted from the scene. For that I overloaded the Dispose function to delete the external info from its container.
When I saw that the data were not deleting properly, I proceeded to debug and discovered a couple of things. First, there is a lot of calls being done to my custom RenderMaterial even if its not present in the scene, and this is messing somewhat with my external data by adding extra unnecessary instances. Why is the RenderMaterial constructor being called up to six times to generate a single render material?
This gets cleand up eventually when the corresponding dispose functions get called, but in certain cases (due to code on my side) it leads to undeleted info.
The trouble comes when, even it the material is deleted successfully from the material list on the UI, my data don’t dissapear properly.
I imagine the material might not be deleted for Undo/redo purposes, but if that is so, how would you suggest me getting my data deleted? I can manage the undo/redo on my side, but I’m somewhat confused on how would I get the proper events to signal me to do so and why the materials are created so many times.
Thanks in advance