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}),
|
config: new Wintersky.Config(json_content, {path}),
|
||||||
emitters: {}
|
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) {
|
loadFile(file, animation_filter) {
|
||||||
@ -1654,6 +1667,15 @@ Blockbench.on('update_camera_position', e => {
|
|||||||
Animator.updateMotionTrailScale();
|
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 = {
|
Animator.MolangParser.global_variables = {
|
||||||
'true': 1,
|
'true': 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user