I'm trying to register an object pointer to type ParticleSystem, so that I can use it for a prop_search, but the pointer is set to read-only by default, which causes an error. Here is a simplified example of what I'm doing:
def register():
bpy.types.ParticleSystem.my_pointer = bpy.types.PointerProperty(type=bpy.types.Object, name="My Pointer")
def draw_panel(self, context):
for ps in context.object.particle_systems:
box = layout.box()
box.prop(ps, "name")
box.prop_search(ps, "my_pointer", context.scene, "objects", icon="OBJECT_DATA", text="target object")
The boxes and particle system names are rendered, but the prop_search throws an error and isn't rendered.
Here is the error:
<_PropertyDeferred, <built-in function PointerProperty>, {'type': <class 'bpy_types.Object'>, 'name': 'My Pointer'}>
rna_uiItemPointerR: property not found: ParticleSystem.my_pointer
If I try to set the value of the pointer in the console it tells me that the property is read-only.
Is there a workaround for this? How can I have an object pointer that is unique for each particle system? I'm looking for a solution that doesn't rely on particle system names.