初步加入内发光,整理项目结构
This commit is contained in:
34
assets/scripts/GlowInnerEffectScene.ts
Normal file
34
assets/scripts/GlowInnerEffectScene.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class GlowInnerEffectScene extends cc.Component {
|
||||
@property(cc.Node)
|
||||
examplesParentNode: cc.Node = null;
|
||||
|
||||
start() {
|
||||
this._updateRenderComponentOutterGlowMaterial(0);
|
||||
}
|
||||
|
||||
onSideCallBack(slider: cc.Slider, customEventData: string) {
|
||||
this._updateRenderComponentOutterGlowMaterial(slider.progress / 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新渲染组件的材质
|
||||
*
|
||||
* 1. 获取材质
|
||||
* 2. 给材质的自定义 unitform 变量赋值
|
||||
* 3. 重新将材质赋值回去
|
||||
*
|
||||
* @param size 描边长度比例[0,1] 比如0.5,那么就是宽*0.5 高*0.5
|
||||
*/
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
9
assets/scripts/GlowInnerEffectScene.ts.meta
Normal file
9
assets/scripts/GlowInnerEffectScene.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "eebe516b-e5b8-4c3b-b22c-a30a0b5bf629",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class OutterGlowEffectScene extends cc.Component {
|
||||
export default class GlowOutterEffectScene extends cc.Component {
|
||||
@property(cc.Node)
|
||||
examplesParentNode: cc.Node = null;
|
||||
|
Reference in New Issue
Block a user