material-maker/addons/material_maker/engine/gen_ios.gd

55 lines
1.3 KiB
GDScript3
Raw Normal View History

tool
extends MMGenBase
class_name MMGenIOs
"""
IOs just forward their inputs to their outputs and are used to specify graph interfaces
"""
var ports : Array = []
2019-10-24 09:00:31 +02:00
func can_be_deleted() -> bool:
return name != "gen_inputs" and name != "gen_outputs"
func get_type() -> String:
return "ios"
func get_type_name() -> String:
match name:
"gen_inputs": return "Inputs"
"gen_outputs": return "Outputs"
_: return "IOs"
func get_io_defs() -> Array:
var rv : Array = []
for p in ports:
rv.push_back({ name=p.name, type="rgba" })
return rv
func get_input_defs() -> Array:
return [] if name == "gen_inputs" else get_io_defs()
func get_output_defs() -> Array:
return [] if name == "gen_outputs" else get_io_defs()
func source_changed(input_index : int) -> void:
2019-09-22 22:17:26 +02:00
if name == "gen_outputs":
if get_parent() != null:
get_parent().notify_output_change(input_index)
2019-09-22 22:17:26 +02:00
else:
notify_output_change(input_index)
func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -> Dictionary:
var source = get_source(output_index)
if source != null:
var rv = source.generator._get_shader_code(uv, source.output_index, context)
while rv is GDScriptFunctionState:
rv = yield(rv, "completed")
return rv
return { defs="", code="", textures={} }
func _serialize(data: Dictionary) -> Dictionary:
2019-09-22 22:17:26 +02:00
data.type = "ios"
data.ports = ports
return data