feat: added "-detailoutline" model import flag
This commit is contained in:
parent
b89eccb62d
commit
b422998e25
1 changed files with 11 additions and 5 deletions
|
|
@ -3,7 +3,6 @@ extends EditorScenePostImport
|
||||||
|
|
||||||
var regular_outline_material : StandardMaterial3D
|
var regular_outline_material : StandardMaterial3D
|
||||||
var character_outline_material : StandardMaterial3D
|
var character_outline_material : StandardMaterial3D
|
||||||
var outline_disable_flag : String = "-nooutline"
|
|
||||||
|
|
||||||
func _post_import(root : Node):
|
func _post_import(root : Node):
|
||||||
regular_outline_material = ResourceLoader.load("res://assets/style/base_outline_material.tres") as StandardMaterial3D
|
regular_outline_material = ResourceLoader.load("res://assets/style/base_outline_material.tres") as StandardMaterial3D
|
||||||
|
|
@ -11,13 +10,20 @@ func _post_import(root : Node):
|
||||||
apply_outline_recursive(root)
|
apply_outline_recursive(root)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
func get_flag(node : Node, flag : String) -> bool:
|
||||||
|
if node.name.contains(flag):
|
||||||
|
node.name = node.name.erase(node.name.find(flag), flag.length())
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
return false
|
||||||
|
|
||||||
func apply_outline_recursive(node : Node):
|
func apply_outline_recursive(node : Node):
|
||||||
if node != null:
|
if node != null:
|
||||||
if node.name.contains(outline_disable_flag):
|
var outline : bool = not get_flag(node, "-nooutline")
|
||||||
node.name = node.name.erase(node.name.find(outline_disable_flag), outline_disable_flag.length())
|
if outline and node is MeshInstance3D:
|
||||||
elif node is MeshInstance3D:
|
var detail : bool = get_flag(node, "-detailoutline")
|
||||||
var mesh : MeshInstance3D = (node as MeshInstance3D)
|
var mesh : MeshInstance3D = (node as MeshInstance3D)
|
||||||
if mesh.skeleton and character_outline_material:
|
if detail and character_outline_material:
|
||||||
mesh.material_overlay = character_outline_material
|
mesh.material_overlay = character_outline_material
|
||||||
elif regular_outline_material:
|
elif regular_outline_material:
|
||||||
mesh.material_overlay = regular_outline_material
|
mesh.material_overlay = regular_outline_material
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue