try use pointer property for rail_uv
This commit is contained in:
parent
612c641391
commit
a8203dcb9c
@ -77,6 +77,7 @@ class BALLANCE_MT_AddFloorMenu(bpy.types.Menu):
|
|||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
preferences.BallanceBlenderPluginPreferences,
|
preferences.BallanceBlenderPluginPreferences,
|
||||||
|
preferences.MyPropertyGroup,
|
||||||
|
|
||||||
bm_import_export.BALLANCE_OT_import_bm,
|
bm_import_export.BALLANCE_OT_import_bm,
|
||||||
bm_import_export.BALLANCE_OT_export_bm,
|
bm_import_export.BALLANCE_OT_export_bm,
|
||||||
@ -117,6 +118,8 @@ def register():
|
|||||||
|
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
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_import.append(menu_func_bm_import)
|
||||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_bm_export)
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_bm_export)
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
import bpy
|
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):
|
class BallanceBlenderPluginPreferences(bpy.types.AddonPreferences):
|
||||||
bl_idname = __package__
|
bl_idname = __package__
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import bpy,bmesh
|
import bpy,bmesh
|
||||||
from . import utils
|
import bpy.types
|
||||||
|
from . import utils, preferences
|
||||||
|
|
||||||
class BALLANCE_OT_rail_uv(bpy.types.Operator):
|
class BALLANCE_OT_rail_uv(bpy.types.Operator):
|
||||||
"""Create a UV for rail"""
|
"""Create a UV for rail"""
|
||||||
@ -7,14 +8,42 @@ class BALLANCE_OT_rail_uv(bpy.types.Operator):
|
|||||||
bl_label = "Create Rail UV"
|
bl_label = "Create Rail UV"
|
||||||
bl_options = {'UNDO'}
|
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
|
@classmethod
|
||||||
def poll(self, context):
|
def poll(self, context):
|
||||||
return check_rail_target()
|
return check_rail_target()
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
wm = context.window_manager
|
||||||
|
return wm.invoke_props_dialog(self)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
create_rail_uv()
|
create_rail_uv()
|
||||||
return {'FINISHED'}
|
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
|
# ====================== method
|
||||||
|
|
||||||
def check_rail_target():
|
def check_rail_target():
|
||||||
|
Loading…
Reference in New Issue
Block a user