diff --git a/ballance_blender_plugin/__init__.py b/ballance_blender_plugin/__init__.py index 4f8ace2..460646c 100644 --- a/ballance_blender_plugin/__init__.py +++ b/ballance_blender_plugin/__init__.py @@ -77,6 +77,7 @@ class BALLANCE_MT_AddFloorMenu(bpy.types.Menu): classes = ( preferences.BallanceBlenderPluginPreferences, + preferences.MyPropertyGroup, bm_import_export.BALLANCE_OT_import_bm, bm_import_export.BALLANCE_OT_export_bm, @@ -117,6 +118,8 @@ def register(): for cls in classes: bpy.utils.register_class(cls) + + bpy.types.Scene.BallanceBlenderPluginProperty = bpy.props.PointerProperty(type=preferences.MyPropertyGroup) bpy.types.TOPBAR_MT_file_import.append(menu_func_bm_import) bpy.types.TOPBAR_MT_file_export.append(menu_func_bm_export) diff --git a/ballance_blender_plugin/preferences.py b/ballance_blender_plugin/preferences.py index 044ae2c..0666b3a 100644 --- a/ballance_blender_plugin/preferences.py +++ b/ballance_blender_plugin/preferences.py @@ -1,4 +1,12 @@ import bpy +import bpy.types + +class MyPropertyGroup(bpy.types.PropertyGroup): + material_picker : bpy.props.PointerProperty( + type=bpy.types.Material, + name="Material", + description="The material used for rail" + ) class BallanceBlenderPluginPreferences(bpy.types.AddonPreferences): bl_idname = __package__ diff --git a/ballance_blender_plugin/rail_uv.py b/ballance_blender_plugin/rail_uv.py index 29a7e49..d0b1fe8 100644 --- a/ballance_blender_plugin/rail_uv.py +++ b/ballance_blender_plugin/rail_uv.py @@ -1,5 +1,6 @@ import bpy,bmesh -from . import utils +import bpy.types +from . import utils, preferences class BALLANCE_OT_rail_uv(bpy.types.Operator): """Create a UV for rail""" @@ -7,14 +8,42 @@ class BALLANCE_OT_rail_uv(bpy.types.Operator): bl_label = "Create Rail UV" bl_options = {'UNDO'} + uv_type: bpy.props.EnumProperty( + name="Type", + description="Define how to create UV", + items=( + ("POINT", "Point", "All UV will be created in a specific point"), + ("UNIFORM", "Uniform", "All UV will be created within 1x1"), + ("SCALE", "Scale", "Give a scale number to scale UV") + ), + ) + + uv_scale : bpy.props.FloatProperty( + name="Scale", + description="The scale of UV", + min=0.0, + default=1.0, + ) + @classmethod def poll(self, context): return check_rail_target() + def invoke(self, context, event): + wm = context.window_manager + return wm.invoke_props_dialog(self) + def execute(self, context): create_rail_uv() return {'FINISHED'} + def draw(self, context): + layout = self.layout + layout.prop(self, "uv_type") + layout.prop(context.scene.BallanceBlenderPluginProperty, "material_picker") + if self.uv_type == 'SCALE': + layout.prop(self, "uv_scale") + # ====================== method def check_rail_target():