How can I create a panel that allows me to add custom properties (StringProperty, BoolProperty, etc) for Collections? I want to show a GUI in the object properties when the user clicks a collection in the outliner. To create a panel you normally inherit from bpy.types.Panel and implement the draw(). The poll() function can be used to determine if the panel should be shown or not. The obvious approach is to use this feature. But how would this poll() look like? How do you know if a collection has been clicked by the user as shown in the screenshot below.
When "my-collection" is clicked/selected I want to show a panel in the object properties. But how do I know if a collection has been clicked?
Update 1
I'll try to clarify the issue a bit more. In the image above I've made the "Sub" collection active. When I print the name C.collection.name you see that it prints "Sub". Now, let me make "Cube" active:
Now, when I print C.collection.name it prints "Sub" again; and although that's correct, that's not the info I'm trying to retrieve. I need to query some other context value which would give me the collection when "Sub" is active and "Cube" when the object is active.




return context.collection.name == "MyCollection"as an example. 2. Theactive_layer_collectionalso has a value when I select an object in in the collection itself. I want to know when the collection is selected/active in the outliner; like if it has the blue background (not sure how to describe this better). Then I can toggle a gui for the object or for the collection. – roxlu Aug 17 '20 at 07:43C.collection, it's a reference so you've got access to all properties of that collection. In case you want to display properties per collections or per object in context, you don't need any poll method, would basically always be true -> Just add a condition to your draw method whether an object or collection is selected or just for both, done. @roxlu Does that help? – brockmann Aug 17 '20 at 09:48