初步加入内发光,整理项目结构

This commit is contained in:
caizhitao
2019-12-20 10:58:26 +08:00
parent f383b8edec
commit 540992a719
18 changed files with 2051 additions and 12 deletions

View 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);
});
});
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "eebe516b-e5b8-4c3b-b22c-a30a0b5bf629",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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;