mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-27 10:04:10 +00:00
better serialization
This commit is contained in:
parent
bf075b41ef
commit
0e62da4d19
@ -26,7 +26,7 @@ conversion_tables = {
|
|||||||
"bevy_color::linear_rgba::LinearRgba": lambda value: "LinearRgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
"bevy_color::linear_rgba::LinearRgba": lambda value: "LinearRgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
||||||
"bevy_color::hsva::Hsva": lambda value: "Hsva(hue:"+str(value[0])+ ", saturation:"+str(value[1])+ ", value:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
"bevy_color::hsva::Hsva": lambda value: "Hsva(hue:"+str(value[0])+ ", saturation:"+str(value[1])+ ", value:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
||||||
|
|
||||||
"bevy_ecs::entity::Entity": lambda value: 'Entity(name: "' + str(value.name) + '")'
|
"bevy_ecs::entity::Entity": lambda value: 'Entity(name: ' + ('Some("' + str(value.name) + '")') if value is not None else "None" + ')'
|
||||||
}
|
}
|
||||||
|
|
||||||
#converts the value of a property group(no matter its complexity) into a single custom property value
|
#converts the value of a property group(no matter its complexity) into a single custom property value
|
||||||
|
@ -128,8 +128,14 @@ def parse_color_hsva(value, caster, typeName):
|
|||||||
return [caster(parsed['hue']), caster(parsed['saturation']), caster(parsed['value']), caster(parsed['alpha'])]
|
return [caster(parsed['hue']), caster(parsed['saturation']), caster(parsed['value']), caster(parsed['alpha'])]
|
||||||
|
|
||||||
def parse_entity(value):
|
def parse_entity(value):
|
||||||
parsed = parse_struct_string(value.replace("Entity","").replace("(", "").replace(")","").replace('"', ""))
|
# strip 'Entity(name: <VAL>)' to just '<VAL>'
|
||||||
bpy.context.scene.objects[parsed["name"]]
|
value = value[13:-1]
|
||||||
|
if value.startswith("Some"):
|
||||||
|
# strip 'Some("<VAL>")' to just '<VAL>'
|
||||||
|
value = value[6:-2]
|
||||||
|
return bpy.context.scene.objects[value]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def to_int(input):
|
def to_int(input):
|
||||||
return int(float(input))
|
return int(float(input))
|
||||||
|
Loading…
Reference in New Issue
Block a user