Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bl_info = {
- "name": "Add-on Template",
- "description": "",
- "author": "p2or",
- "version": (0, 0, 3),
- "blender": (2, 80, 0),
- "location": "3D View > Tools",
- "warning": "", # used for warning icon and text in addons panel
- "wiki_url": "",
- "tracker_url": "",
- "category": "Development"
- }
- import bpy
- from bpy.props import (StringProperty,
- BoolProperty,
- IntProperty,
- FloatProperty,
- FloatVectorProperty,
- EnumProperty,
- PointerProperty,
- )
- from bpy.types import (Panel,
- Menu,
- Operator,
- PropertyGroup,
- )
- # ------------------------------------------------------------------------
- # Scene Properties
- # ------------------------------------------------------------------------
- def my_callback(scene, context):
- items = [
- ('GA', "Asset", "tooltip"),
- ('LP', "Low", "tooltip"),
- ('HP', "High", "High Poly"),
- ]
- return items
- class MyProperties(PropertyGroup):
- my_bool: BoolProperty(
- name="Enable or Disable",
- description="A bool property",
- default = False
- )
- # define asset mode types
- fbx_mode: EnumProperty(
- name="Dropdown:",
- description="Apply Data to attribute.",
- items=my_callback
- )
- # collection spawner
- fbx_spawner: EnumProperty(
- name="File Spawners",
- options={'ENUM_FLAG'},
- items=my_callback,
- description="tooltip",
- )
- # ------------------------------------------------------------------------
- # Panel in Object Mode
- # ------------------------------------------------------------------------
- class OBJECT_PT_CustomPanel(Panel):
- bl_label = "My Panel"
- bl_idname = "OBJECT_PT_custom_panel"
- bl_space_type = "VIEW_3D"
- bl_region_type = "UI"
- bl_category = "Tools"
- bl_context = "objectmode"
- @classmethod
- def poll(self,context):
- return context.object is not None
- def draw(self, context):
- layout = self.layout
- scene = context.scene
- mytool = scene.my_tool
- layout.prop(mytool, "my_bool")
- layout.prop(mytool, "fbx_mode", text="")
- layout.label(text="Spawner:")
- layout.prop(mytool, "fbx_spawner") #?
- # Alternatively expand the property:
- layout.prop(mytool, "fbx_mode", expand=True)
- layout.separator()
- # ------------------------------------------------------------------------
- # Registration
- # ------------------------------------------------------------------------
- classes = (
- MyProperties,
- OBJECT_PT_CustomPanel
- )
- def register():
- from bpy.utils import register_class
- for cls in classes:
- register_class(cls)
- bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)
- def unregister():
- from bpy.utils import unregister_class
- for cls in reversed(classes):
- unregister_class(cls)
- del bpy.types.Scene.my_tool
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement