Files
cocos4/cocos/rendering/post-process/components/blit-screen.ts
T
minggo 7ef995b655 Merge branch 'v3.8.0' into v3.8.1-merge-v3.8.0
Conflicts:
	cocos/3d/lights/spot-light-component.ts
	cocos/animation/event/event-emitter.ts
	cocos/physics-2d/box2d/physics-contact.ts
	cocos/physics-2d/box2d/physics-world.ts
	cocos/physics-2d/box2d/platform/physics-contact-listener.ts
	cocos/physics-2d/builtin/builtin-world.ts
	cocos/physics/framework/components/constraints/configurable-constraint.ts
	cocos/spine/assembler/simple.ts
	cocos/spine/skeleton.ts
	native/cocos/editor-support/spine-wasm/spine-model.cpp
	native/cocos/editor-support/spine-wasm/spine-model.h
	native/cocos/editor-support/spine-wasm/spine-skeleton-instance.cpp
	native/cocos/editor-support/spine-wasm/spine-skeleton-instance.h
	native/cocos/editor-support/spine-wasm/spine-type-export.cpp
	native/external-config.json
2023-07-03 15:25:13 +08:00

81 lines
2.2 KiB
TypeScript

import { EDITOR } from 'internal:constants';
import { Material } from '../../../asset/assets';
import { property } from '../../../core/data/class-decorator';
import { ccclass, disallowMultiple, executeInEditMode, help, menu } from '../../../core/data/decorators';
import { PostProcessSetting } from './post-process-setting';
@ccclass('cc.BlitScreenMaterial')
class BlitScreenMaterial {
@property(Material)
_material: Material | undefined;
@property(Material)
get material (): Material | undefined {
return this._material;
}
set material (v) {
this._material = v;
}
@property
enable = true
}
@ccclass('cc.BlitScreen')
@help('cc.BlitScreen')
@menu('PostProcess/BlitScreen')
@disallowMultiple
@executeInEditMode
export class BlitScreen extends PostProcessSetting {
@property(Material)
_activeMaterials: Material[] = []
@property({ type: Material, visible: false })
get activeMaterials (): Material[] {
return this._activeMaterials;
}
set activeMaterials (v) {
this._activeMaterials = v;
for (let i = 0; i < this._materials.length; i++) {
for (let j = 0; j < v.length; j++) {
if (this._materials[i] && v[j]) {
if (this._materials[i].material?.uuid === v[j].uuid) {
this._materials[i].material = v[j];
}
}
}
}
}
@property(BlitScreenMaterial)
_materials: BlitScreenMaterial[] = []
@property(BlitScreenMaterial)
get materials (): BlitScreenMaterial[] {
return this._materials;
}
set materials (v) {
this._materials = v;
if (EDITOR) {
setTimeout(() => {
globalThis.cce.Engine.repaintInEditMode();
}, 50);
}
this.updateActiveMateirals();
}
updateActiveMateirals (): void {
const materials = this._materials;
this._activeMaterials.length = 0;
for (let i = 0; i < materials.length; i++) {
const m = materials[i];
if (m.enable && m.material) {
this._activeMaterials.push(m.material);
}
}
}
onLoad (): void {
this.updateActiveMateirals();
}
}