mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Automatically reload particles on file change
This commit is contained in:
parent
994d955820
commit
cd47331a67
@ -1408,6 +1408,19 @@ const Animator = {
|
||||
config: new Wintersky.Config(json_content, {path}),
|
||||
emitters: {}
|
||||
};
|
||||
if (isApp) {
|
||||
let timeout;
|
||||
this.watcher = fs.watch(path, (eventType) => {
|
||||
if (eventType == 'change') {
|
||||
if (timeout) clearTimeout(timeout)
|
||||
timeout = setTimeout(() => {
|
||||
Blockbench.read(path, {errorbox: false}, (files) => {
|
||||
Animator.loadParticleEmitter(path, files[0].content);
|
||||
})
|
||||
}, 60)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
loadFile(file, animation_filter) {
|
||||
@ -1654,6 +1667,15 @@ Blockbench.on('update_camera_position', e => {
|
||||
Animator.updateMotionTrailScale();
|
||||
}
|
||||
})
|
||||
Blockbench.on('reset_project', () => {
|
||||
for (let path in Animator.particle_effects) {
|
||||
let effect = Animator.particle_effects[path];
|
||||
if (isApp && effect.watcher) {
|
||||
effect.watcher.close()
|
||||
}
|
||||
delete Animator.particle_effects[path];
|
||||
}
|
||||
})
|
||||
|
||||
Animator.MolangParser.global_variables = {
|
||||
'true': 1,
|
||||
|
Loading…
Reference in New Issue
Block a user