30 lines
782 B
GDScript
30 lines
782 B
GDScript
extends MeshInstance
|
|
|
|
onready var is_mouse_over = false
|
|
var old_material_override = Material.new()
|
|
|
|
signal tile_selected
|
|
signal tile_mouse_entered
|
|
|
|
|
|
func _on_Area_mouse_entered():
|
|
is_mouse_over = true
|
|
old_material_override = material_override
|
|
|
|
var material = self.get_surface_material(0)
|
|
var cloned_material = material.duplicate()
|
|
cloned_material.albedo_color = Color (1, 0, 0)
|
|
self.material_override = cloned_material
|
|
emit_signal("tile_mouse_entered", self)
|
|
|
|
|
|
func _on_Area_mouse_exited():
|
|
is_mouse_over = false
|
|
self.material_override = old_material_override
|
|
|
|
|
|
func _on_Area_input_event(camera, event, position, normal, shape_idx):
|
|
if is_mouse_over and event is InputEventMouseButton:
|
|
if event.button_index == 1 and event.pressed:
|
|
emit_signal("tile_selected", self)
|