-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edit hairstyles and hair color
154 lines (131 loc) · 3.81 KB
/
Edit hairstyles and hair color
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
extends Node
onready var hair_attachment = $"../Mesh/Armature/Skeleton/Hair"
var hair0: PackedScene = preload("res://player/FHuman/hair/hair0/hair0.tscn")
var hair1: PackedScene = preload("res://player/FHuman/hair/hair1/hair1.tscn")
var hair2: PackedScene = preload("res://player/FHuman/hair/hair2/hair2.tscn")
var hair3: PackedScene = preload("res://player/FHuman/hair/hair3/hair3.tscn")
var hair4: PackedScene = preload("res://player/FHuman/hair/hair0/hair0.glb")
var hair5: PackedScene = preload("res://player/FHuman/hair/hair0/hair0.glb")
var hair_color: Color = Color(1, 1, 1) # Default color
var current_hair_instance: Node = null
var has_hair0 = false
var has_hair1 = false
var has_hair2 = false
var has_hair3 = false
var has_hair4 = false
var has_hair5 = false
func _ready():
switchHair()
func switchHair():
if current_hair_instance:
current_hair_instance.queue_free() # Remove the current hair instance
if has_hair0:
instanceHair0()
elif has_hair1:
instanceHair1()
elif has_hair2:
instanceHair2()
elif has_hair3:
instanceHair3()
elif has_hair4:
instanceHair4()
elif has_hair5:
instanceHair5()
else:
instanceHair0()
# Add cases for other hair options
func _physics_process(delta):
switchHair()
func instanceHair0():
if hair_attachment and hair0:
var hair_instance = hair0.instance()
hair_attachment.add_child(hair_instance)
current_hair_instance = hair_instance
colorhair()
func instanceHair1():
if hair_attachment and hair1:
var hair_instance = hair1.instance()
hair_attachment.add_child(hair_instance)
current_hair_instance = hair_instance
colorhair()
func instanceHair2():
if hair_attachment and hair2:
var hair_instance = hair2.instance()
hair_attachment.add_child(hair_instance)
current_hair_instance = hair_instance
colorhair()
func instanceHair3():
if hair_attachment and hair3:
var hair_instance = hair3.instance()
hair_attachment.add_child(hair_instance)
current_hair_instance = hair_instance
colorhair()
func instanceHair4():
if hair_attachment and hair4:
var hair_instance = hair4.instance()
hair_attachment.add_child(hair_instance)
current_hair_instance = hair_instance
var hair_material = current_hair_instance.material_override
if hair_material:
# Set the color property of the material
hair_material.albedo_color = hair_color
func instanceHair5():
if hair_attachment and hair5:
var hair_instance = hair5.instance()
hair_attachment.add_child(hair_instance)
current_hair_instance = hair_instance
func colorhair():
var hair_material = current_hair_instance.material_override
if hair_material:
# Set the color property of the material
hair_material.albedo_color = hair_color
func _on_hair0_pressed():
has_hair0 = true
has_hair1 = false
has_hair2 = false
has_hair3 = false
has_hair4 = false
has_hair5 = false
func _on_hair1_pressed():
has_hair0 = false
has_hair1 = true
has_hair2 = false
has_hair3 = false
has_hair4 = false
has_hair5 = false
func _on_hair2_pressed():
has_hair0 = false
has_hair1 = false
has_hair2 = true
has_hair3 = false
has_hair4 = false
has_hair5 = false
func _on_hair3_pressed():
has_hair0 = false
has_hair1 = false
has_hair2 = false
has_hair3 = true
has_hair4 = false
has_hair5 = false
func _on_hair4_pressed():
has_hair0 = false
has_hair1 = false
has_hair2 = false
has_hair3 = false
has_hair4 = true
has_hair5 = false
func _on_hair5_pressed():
has_hair0 = false
has_hair1 = false
has_hair2 = false
has_hair3 = false
has_hair4 = false
has_hair5 = true
func _on_ColorPicker_color_changed(color):
if current_hair_instance:
# Assuming your hair models have a material with a color property
var hair_material = current_hair_instance.material_override
if hair_material:
# Set the color property of the material
hair_material.albedo_color = color
hair_color = color