- Creator 版本:3.6.1
按照官网的代码的实现死亡消融的效果。贴图溶解_哔哩哔哩_bilibili
Sprite 可以在 Update 动态修改。骨骼不行。代码如下:
dissolveThreshold = 0;
spComp: sp.Skeleton = null;
mat: Material = null;
dissolve = true;
handle = -1;
start() {
this.spComp = this.getComponent(sp.Skeleton);
this.mat = this.spComp.customMaterial;
console.log(this.mat.passes);
// 这样可以
// this.mat.setProperty('dissolveThreshold', 0.5);
}
processPass(pass) {
this.handle = pass.getHandle('dissolveThreshold');
pass.setUniform(this.handle, this.dissolveThreshold);
pass.update();
}
update(deltaTime: number) {
const pass = this.mat.passes[0];
if (this.dissolve) {
this.dissolveThreshold += 0.5 * deltaTime;
if (this.dissolveThreshold > 1) {
this.dissolveThreshold = 1;
this.dissolve = false;
}
}
this.processPass(pass);
}
因为上传大小限制,提供资源问题。
assets.zip (535.3 KB)
