I'm creating an Add-on where you have to select any object type to start using it. but I would like to know if is there any way to display a red property input if no object is selected or exists.

enter image description here

  • This image is an screenshot of driver editor pop-up

enter image description here


Yes. Just set Layout.alert property to True in case there is no object selected:

Demo based on @batFINGERs answer to Object selection box with eyedropper.

import bpy
from bpy.props import PointerProperty

class TEST_PT_layout_panel(bpy.types.Panel):
    bl_label = "Prop Panels"
    bl_category = "Test Panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        if not scene.prop:
            col.alert = True
            col.alert = False
        col.prop(scene, "prop")

def register():
    bpy.types.Scene.prop = PointerProperty(type=bpy.types.Object)

def unregister():
if __name__ == "__main__":

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.