CocosCreator-Shader-Effect-.../assets/scripts/OutterGlowEffectScene.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-12-19 02:52:32 +00:00
const { ccclass, property } = cc._decorator;
@ccclass
2019-12-19 08:25:44 +00:00
export default class OutterGlowEffectScene extends cc.Component {
@property(cc.Node)
examplesParentNode: cc.Node = null;
2019-12-19 02:52:32 +00:00
start() {
2019-12-19 08:25:44 +00:00
this._updateRenderComponentOutterGlowMaterial(0);
2019-12-19 02:52:32 +00:00
}
onSideCallBack(slider: cc.Slider, customEventData: string) {
2019-12-19 08:25:44 +00:00
this._updateRenderComponentOutterGlowMaterial(slider.progress / 100);
2019-12-19 02:52:32 +00:00
}
/**
2019-12-19 08:25:44 +00:00
*
2019-12-19 02:52:32 +00:00
*
* 1.
* 2. unitform
* 3.
*
2019-12-19 08:25:44 +00:00
* @param size [0,1] 0.5*0.5 *0.5
2019-12-19 02:52:32 +00:00
*/
2019-12-19 08:25:44 +00:00
private _updateRenderComponentOutterGlowMaterial(size: number) {
this.examplesParentNode.children.forEach(childNode => {
childNode.getComponents(cc.RenderComponent).forEach(renderComponent => {
let material: cc.Material = renderComponent.getMaterial(0);
material.setProperty("outlineSize", size);
renderComponent.setMaterial(0, material);
});
});
2019-12-19 02:52:32 +00:00
}
}