new outline shader
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
|
||||
@export var meshInstance: MeshInstance3D
|
||||
@export var preview_shader: ShaderMaterial
|
||||
|
||||
var default_shaders: Array
|
||||
var staic_body: StaticBody3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Global.preview_created.connect(_on_preview_create)
|
||||
Global.object_placed.connect(_on_object_placed)
|
||||
set_default_shaders()
|
||||
|
||||
staic_body = $StaticBody3D
|
||||
staic_body.mouse_entered.connect(_on_mouse_enter)
|
||||
staic_body.mouse_exited.connect(_on_mouse_exit)
|
||||
print(staic_body)
|
||||
|
||||
|
||||
func set_default_shaders():
|
||||
@@ -46,3 +54,22 @@ func _on_preview_create():
|
||||
|
||||
func _on_object_placed():
|
||||
restore_default_shaders()
|
||||
|
||||
|
||||
func enable_outline():
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", true)
|
||||
func disable_outline():
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", false)
|
||||
|
||||
|
||||
|
||||
func _on_mouse_enter():
|
||||
enable_outline()
|
||||
func _on_mouse_exit():
|
||||
disable_outline()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
extends StaticBody3D
|
||||
|
||||
|
||||
|
||||
@onready var beds = preload("res://Scenes/Prefabs/DoubleBeds.tscn")
|
||||
@export var buildTransparentPreivew: MeshInstance3D
|
||||
|
||||
|
||||
@@ -49,6 +46,7 @@ func place_object():
|
||||
is_placed = true
|
||||
buildTransparentPreivew.visible = false
|
||||
Global.object_placed.emit()
|
||||
self.queue_free()
|
||||
|
||||
func _on_enter_build_mode():
|
||||
if !is_placed:
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var outline_shader = preload("res://Shaders/outline.gdshader")
|
||||
|
||||
@export var debugLabel1: Label
|
||||
|
||||
signal exit_build_mode
|
||||
@@ -11,6 +14,8 @@ signal object_placed
|
||||
|
||||
var build_mode: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
print(outline_shader)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_released("enter_build_mode"):
|
||||
|
||||
Reference in New Issue
Block a user