Fixed a bug that allowed Material to be duplicated

This commit is contained in:
RodZill4 2019-11-22 07:47:45 +01:00
parent 4542c2d22e
commit 8650a5ae40
2 changed files with 11 additions and 2 deletions

View File

@ -96,6 +96,15 @@ func get_port_targets(gen_name: String, output_index: int) -> Array:
func add_generator(generator : MMGenBase) -> bool: func add_generator(generator : MMGenBase) -> bool:
var name = generator.name var name = generator.name
if generator.name == "Material":
if has_node("Material"):
# Cannot create a material if it exists already
return false
else:
var parent = get_parent()
if parent != null and parent is Object and parent.get_script() == get_script():
# Material is always in top level graph
return false
var index = 1 var index = 1
while has_node(name): while has_node(name):
index += 1 index += 1

View File

@ -24,8 +24,8 @@ static func add_to_gen_graph(gen_graph, generators, connections) -> Dictionary:
var g = create_gen(n) var g = create_gen(n)
if g != null: if g != null:
var orig_name = g.name var orig_name = g.name
gen_graph.add_generator(g) if gen_graph.add_generator(g):
rv.generators.append(g) rv.generators.append(g)
gennames[orig_name] = g.name gennames[orig_name] = g.name
for c in connections: for c in connections:
if gennames.has(c.from) and gennames.has(c.to): if gennames.has(c.from) and gennames.has(c.to):