diff --git a/rigify/generate.py b/rigify/generate.py
index 1134b6d6025cdbfa35b30fe679449418b197c591..c9eec71f588284dcaf7cf518980497b26f529495 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -26,7 +26,7 @@ from rigify.utils import ORG_PREFIX, MCH_PREFIX, DEF_PREFIX, WGT_PREFIX, ROOT_NA
 from rigify.utils import RIG_DIR
 from rigify.utils import create_root_widget
 from rigify.utils import random_string
-from rigify.rig_ui_template import UI_SLIDERS, layers_ui
+from rigify.rig_ui_template import UI_SLIDERS, layers_ui, UI_REGISTER
 from rigify import rigs
 
 RIG_MODULE = "rigs"
@@ -292,6 +292,7 @@ def generate_rig(context, metarig):
     for s in ui_scripts:
         script.write("\n        " + s.replace("\n", "\n        ") + "\n")
     script.write(layers_ui(vis_layers))
+    script.write(UI_REGISTER)
     script.use_module = True
 
     t.tick("The rest: ")
diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py
index 82d853a4a5b9bad1ba46562cf4495c94f8a25b55..d9469ad4d85adb4f65486a203a922fa37bc03593 100644
--- a/rigify/rig_ui_template.py
+++ b/rigify/rig_ui_template.py
@@ -94,3 +94,13 @@ class RigLayers(bpy.types.Panel):
 
     return code
 
+
+UI_REGISTER = """
+
+def register():
+    bpy.utils.register_class(RigUI)
+    bpy.utils.register_class(RigLayers)
+
+register()
+"""
+