Skip to content

Commit 8c5faa8

Browse files
committed
Update UniformsView.swift
1 parent 32b60b9 commit 8c5faa8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Sources/MetalBuilder/Uniforms/UniformsView.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,26 @@ public struct UniformsView: View {
5252
}
5353
}
5454
}
55-
.onChange(of: uniforms.bufferAllocated){ _ in
56-
loadInitial()
57-
if uniforms.saveToDefaults && !defaultsLoaded{
58-
print("loadDef")
59-
loadFomDefaults()
60-
defaultsLoaded = true
55+
.onAppear{
56+
if uniforms.bufferAllocated{
57+
startup()
6158
}
6259
}
60+
.onChange(of: uniforms.bufferAllocated){ _ in
61+
startup()
62+
}
6363
}
6464
}
6565
//private methods
6666
extension UniformsView{
67+
func startup(){
68+
loadInitial()
69+
if uniforms.saveToDefaults && !defaultsLoaded{
70+
print("loadDef")
71+
loadFomDefaults()
72+
defaultsLoaded = true
73+
}
74+
}
6775
func saveToDefaults(value: [Float], name: String){
6876
let key = keyForName(name)
6977
print("saved "+key, value)

0 commit comments

Comments
 (0)