3

How to register a single property (not a property group) in blender 2.8?

My attempt

This is what I am doing at the moment inside my addon __init__.py:

# ...
bpy.types.Material.myprop = bpy.props.PointerProperty(type=MyProp)
# ...

with MyProp class:

class MyProp(bpy.types.Property):
    name: "Some name"
    description: "Some description"

The idea is so I can see access this property through:

bpy.data.materials['Material'].myprop

Here's the error I am getting when loading the add-on:

bpy.types.Material.myprop = bpy.props.PointerProperty(type=Myprop)
ValueError: bpy_struct "Material" registration error: myprop could not register
gmagno
  • 402
  • 4
  • 13

1 Answers1

5

Silly me... This is what I was looking for:

bpy.types.Material.myprop = bpy.props.FloatProperty(name="myprop")

Reference:

Assigning property to existing class

gmagno
  • 402
  • 4
  • 13