﻿
export class UIEffect {
    private constructor() { }

    /**
     * 播放一个界面特效
     * @param guid 特效guid
     * @param duration 特效持续时间（秒）
     */
    public static async showUIEffect(guid: string, duration: number) {
        if (SystemUtil.isServer()) { return }
        // 创建特效
        let effect = await GameObjPool.asyncSpawn(guid) as Effect
        // 设置持续时间
        effect.duration = duration
        // 播放完毕回收
        effect.onFinish.add(() => {
            GameObjPool.despawn(effect)
        })
        // 播放特效
        effect.play()
        // 将特效挂到摄像机上
        effect.parent = Camera.currentCamera
        // 设置相对位置
        effect.localTransform.position = new Vector(90, 0, 0)
        // 设置相对旋转
        effect.localTransform.rotation = new Rotation(0, 0, 90)
    }

}