mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-06-23 19:22:47 +08:00
2. 存储模块性能提升,添加LRU缓存、批量操作支持,优化内存使用 3. 多语言模块性能与内存管理优化,组件查询性能提升 4. 时间模块类型安全与性能优化,使用泛型替代any,对象池机制减少内存分配 5. 事件系统修复双重注册、重复注册等严重问题,实现EventData对象池减少GC压力 6. RandomManager修复4个逻辑BUG,包括边界问题和越界问题 7. 音频模块内存与性能优化,避免重复加载,优化数据结构,添加完整清理机制 8. CCView与CCViewVM合并,支持按需启用MVVM 9. Collection模块优化,AsyncQueue添加队列容量限制,Collection查询性能提升 10. ECS系统全面优化,对象池复用减少内存分配,循环性能提升 11. 优化MVVM组件性能
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
|
|
import type { Material } from 'cc';
|
|
import { CCInteger, Component, Sprite, _decorator } from 'cc';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('Ambilight')
|
|
/** 流光效果 */
|
|
export class Ambilight extends Component {
|
|
@property
|
|
_max = 1;
|
|
@property(CCInteger)
|
|
get max(): number {
|
|
return this._max;
|
|
}
|
|
set max(value: number) {
|
|
this._max = value;
|
|
}
|
|
|
|
private _start = 0;
|
|
private _material !: Material;
|
|
private _sprite !: Sprite;
|
|
|
|
onLoad() {
|
|
// 缓存组件和材质引用,避免每帧查询
|
|
this._sprite = this.node.getComponent(Sprite)!;
|
|
if (this._sprite) {
|
|
this._material = this._sprite.getMaterial(0)!;
|
|
}
|
|
}
|
|
|
|
update(dt: number) {
|
|
if (this._material) {
|
|
this._setShaderTime(dt);
|
|
}
|
|
}
|
|
|
|
private _setShaderTime(dt: number) {
|
|
let start = this._start;
|
|
if (start > this.max) start = 0;
|
|
start += 0.015;
|
|
this._material.setProperty('speed', start);
|
|
|
|
this._start = start;
|
|
}
|
|
}
|
|
|