UE4:How to use UParticleModuleEventSendToGame

本文介绍了如何在UE4中利用UParticleModuleEventSendToGame将粒子发射事件发送到游戏。虽然源代码和文档中未提供示例,但通过发送事件、实现派生类、查看成员变量并进行预览设置,可以在运行时实现功能。然而,目前该功能仅在运行时有效,对美术同事不够友好,需要在编辑器中提供预览功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如需转载本文,请声明作者及出处。

UParticleModuleEventSendToGame can send the events of particle emit to the game, but no used example can be found in the source code or document。

To use it, you need to do the following:

1.send events https://github.com/EpicGames/UnrealEngine/pull/1522/commits

2.Implement your derived class

UCLASS()
class UParticleEventXXXX : public UParticleModuleEventSendToGame
{
    GENERATED_UCLASS_BODY()

    //
    Member variables

    virtual void DoEvent(...);
};


void UParticleEventXXXX::DoEvent(...) {
    // any thing
}

3.You can see your derived classes here

 

4.Select your derived class, you can see the member variables

It is derived from Uobject, all these member variables can be serialized and displayed in the UI widget.

5.preview

Now, it only works at runtime.It's not friendly to art colleagues。You need to provide preview function in the editor。

void UParticleSystemComponent::FinalizeTickComponent()
{
   AParticleEventManager* EventManager = (World ? World->MyParticleEventManager : NULL);

 if (EventManager)
 {
            if (SpawnEvents.Num() > 0) 
                EventManager->HandleParticleSpawnEvents(this, SpawnEvents);

            if (DeathEvents.Num() > 0) 
                EventManager->HandleParticleDeathEvents(this, DeathEvents);

            if (CollisionEvents.Num() > 0) 
                EventManager->HandleParticleCollisionEvents(this, CollisionEvents);

            if (BurstEvents.Num() > 0) 
                EventManager->HandleParticleBurstEvents(this, BurstEvents);
  }

}

In edit mode, eventmanager is Null

Just like:

void UParticleSystemComponent::FinalizeTickComponent()
{
    ...
        UWorld* World = GetWorld();
        AParticleEventManager* EventManager = (World ? World->MyParticleEventManager : NULL);
#ifdef WITH_EDITOR
        if (EventManager == NULL && !GEngine->ParticleEventManagerClassPath.IsEmpty())
        {

            setting World->MyParticleEventManager
            EventManager = World->MyParticleEventManager;
        }
#endif 

        if (EventManager)
        {
            if (SpawnEvents.Num() > 0) 
                EventManager->HandleParticleSpawnEvents(this, SpawnEvents);

            if (DeathEvents.Num() > 0) 
                EventManager->HandleParticleDeathEvents(this, DeathEvents);

            if (CollisionEvents.Num() > 0) 
                EventManager->HandleParticleCollisionEvents(this, CollisionEvents);

            if (BurstEvents.Num() > 0) 
                EventManager->HandleParticleBurstEvents(this, BurstEvents);
        }
        ....
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值