mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-08 17:00:08 +01:00
[3.0] Simplify list of branches in the README (#1255)
This commit is contained in:
@@ -20,4 +20,3 @@ func _exit_tree():
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,23 +24,23 @@ func save_file_selected(path):
|
||||
var color = get_node("ColorPicker_albedo").color
|
||||
var metallic = get_node("HSlider_metallic").value
|
||||
var roughness = get_node("HSlider_roughness").value
|
||||
|
||||
|
||||
# Make a new silly resource (which in this case actually is a node)
|
||||
# and initialize it
|
||||
var silly_resource = silly_material_resource.new()
|
||||
silly_resource.init()
|
||||
|
||||
|
||||
# Assign the values
|
||||
silly_resource.albedo_color = color
|
||||
silly_resource.metallic_strength = metallic
|
||||
silly_resource.roughness_strength = roughness
|
||||
|
||||
|
||||
# Make a file, store the silly material as a json string, then close the file.
|
||||
var file = File.new()
|
||||
file.open(path, File.WRITE)
|
||||
file.store_string(silly_resource.make_json())
|
||||
file.close()
|
||||
|
||||
|
||||
return true
|
||||
|
||||
|
||||
@@ -48,19 +48,19 @@ func load_file_selected(path):
|
||||
# Using the passed in editor interface, get the selected nodes in the editor
|
||||
var editor_selection = editor_interface.get_selection()
|
||||
var selected_nodes = editor_selection.get_selected_nodes()
|
||||
|
||||
|
||||
var file = File.new()
|
||||
var SpatialMaterial_Silly = null
|
||||
|
||||
|
||||
# Make a new silly resource (which in this case actually is a node)
|
||||
# and initialize it
|
||||
var silly_resource = silly_material_resource.new()
|
||||
silly_resource.init()
|
||||
|
||||
|
||||
# If the file exists, then open it
|
||||
if file.file_exists(path):
|
||||
file.open(path, File.READ)
|
||||
|
||||
|
||||
# Get the JSON string and convert it into a silly material.
|
||||
var json_dict_as_string = file.get_line()
|
||||
if json_dict_as_string != null:
|
||||
@@ -68,24 +68,24 @@ func load_file_selected(path):
|
||||
else:
|
||||
file.close()
|
||||
return false
|
||||
|
||||
|
||||
# Tell the silly resource (actually a node) to make a material
|
||||
SpatialMaterial_Silly = silly_resource.make_material()
|
||||
|
||||
|
||||
# Go through the selected nodes and see if they have the 'set_surface_material'
|
||||
# function (which only MeshInstance has by default). If they do, then set the material
|
||||
# to the silly material.
|
||||
for node in selected_nodes:
|
||||
if node.has_method("set_surface_material"):
|
||||
node.set_surface_material(0, SpatialMaterial_Silly)
|
||||
|
||||
|
||||
# Close the file and return true (success!)
|
||||
file.close()
|
||||
return true
|
||||
|
||||
|
||||
# If the file does not exist, then return false (failure)
|
||||
else:
|
||||
return false
|
||||
|
||||
|
||||
# If we somehow get here, then return false (failure)
|
||||
return false
|
||||
|
||||
@@ -21,15 +21,15 @@ func init():
|
||||
# into the JSON format
|
||||
func make_json():
|
||||
var json_dict = {}
|
||||
|
||||
|
||||
json_dict["albedo_color"] = {}
|
||||
json_dict["albedo_color"]["r"] = albedo_color.r
|
||||
json_dict["albedo_color"]["g"] = albedo_color.g
|
||||
json_dict["albedo_color"]["b"] = albedo_color.b
|
||||
|
||||
|
||||
json_dict["metallic_strength"] = metallic_strength
|
||||
json_dict["roughness_strength"] = roughness_strength
|
||||
|
||||
|
||||
return to_json(json_dict)
|
||||
|
||||
|
||||
@@ -37,23 +37,23 @@ func make_json():
|
||||
# fill in our data.
|
||||
func from_json(json_dict_as_string):
|
||||
var json_dict = parse_json(json_dict_as_string)
|
||||
|
||||
|
||||
albedo_color.r = json_dict["albedo_color"]["r"]
|
||||
albedo_color.g = json_dict["albedo_color"]["g"]
|
||||
albedo_color.b = json_dict["albedo_color"]["b"]
|
||||
|
||||
|
||||
metallic_strength = json_dict["metallic_strength"]
|
||||
roughness_strength = json_dict["roughness_strength"]
|
||||
|
||||
|
||||
return
|
||||
|
||||
|
||||
# Make a SpatialMaterial using our variables.
|
||||
func make_material():
|
||||
var mat = SpatialMaterial.new()
|
||||
|
||||
|
||||
mat.albedo_color = albedo_color
|
||||
mat.metallic = metallic_strength
|
||||
mat.roughness = roughness_strength
|
||||
|
||||
|
||||
return mat
|
||||
|
||||
@@ -14,10 +14,10 @@ extends EditorPlugin
|
||||
var io_material_dialog;
|
||||
|
||||
func _enter_tree():
|
||||
|
||||
|
||||
io_material_dialog = preload("res://addons/custom_import_plugin/Custom_material_dock.tscn").instance()
|
||||
io_material_dialog.editor_interface = get_editor_interface();
|
||||
|
||||
|
||||
add_control_to_dock(DOCK_SLOT_LEFT_UL, io_material_dialog)
|
||||
|
||||
func _exit_tree():
|
||||
|
||||
@@ -15,4 +15,3 @@ func _exit_tree():
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ addons/custom_node
|
||||
To distribute and install from UI, make a zip that contains the folder,
|
||||
example:
|
||||
|
||||
zip -r custom_node.zip custom_node/*
|
||||
zip -r custom_node.zip custom_node/*
|
||||
|
||||
Reference in New Issue
Block a user