material-maker/material_maker/node_factory.gd

18 lines
505 B
GDScript3
Raw Normal View History

extends Node
var includes
2020-03-21 17:44:41 +01:00
func create_node(model : String, type : String) -> Node:
var node_type = null
var node = null
2020-03-21 17:44:41 +01:00
var file_name = "res://material_maker/nodes/"+model+".tscn"
if ! ResourceLoader.exists(file_name):
file_name = "res://material_maker/nodes/"+type+".tscn"
if ResourceLoader.exists(file_name):
2020-03-21 17:44:41 +01:00
node_type = load(file_name)
if node_type != null:
node = node_type.instance()
if node == null:
node = preload("res://material_maker/nodes/generic.tscn").instance()
return node