I have a type of PropertyGroup that stores some settings. My goal is to have a master collection full of instances of this group stored with the scene, and a list of slots that can be filled with these instances on each material. (Basically replicating Blender's material system but instead of slots for material on objects, it's slots for these instances on materials)
My current issue is that I can't figure out how to properly reference this data in the slots. Here's what I've tried so far:
- Storing the instances directly through PointerProperties. This seems like the obvious solution, but since PointerProperties for custom types can't be re-assigned, you can't reference an item from the master collection in a slot.
- Storing "references" to the items through StringProperties with their names. The items have unique names, so that's not an issue. However, problems arise when renaming, since the item in the master collection and all slots referencing it must have their strings changed. I tried using the getter/setter feature of properties to achieve this synchronization, but encountered lots of strange issues in the process. I think the reason is the threading issue described here, since I'm modifying data from materials (which hold the slots) and the scene (which holds the master list), which are from separate data blocks.
I found this question that has a similar end goal, but it doesn't really address this issue. Is there a known way to do this, or any other project that does something similar?