mirror of
https://github.com/storytold/UE4-OSC.git
synced 2026-10-09 00:09:43 +00:00
add receiver actor
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
#include "OscPrivatePCH.h"
|
||||
#include "OscReceiverActor.h"
|
||||
#include "OscDispatcher.h"
|
||||
|
||||
|
||||
AOscReceiverActor::AOscReceiverActor(const class FPostConstructInitializeProperties& PCIP)
|
||||
: Super(PCIP)
|
||||
{
|
||||
auto instance = UOscDispatcher::Get();
|
||||
if (instance && !HasAnyFlags(RF_ClassDefaultObject))
|
||||
{
|
||||
instance->RegisterReceiver(this);
|
||||
}
|
||||
}
|
||||
|
||||
void AOscReceiverActor::BeginDestroy()
|
||||
{
|
||||
auto instance = UOscDispatcher::Get();
|
||||
if (instance && !HasAnyFlags(RF_ClassDefaultObject))
|
||||
{
|
||||
instance->UnregisterReceiver(this);
|
||||
}
|
||||
|
||||
Super::BeginDestroy();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "OscReceiverInterface.h"
|
||||
#include "OscDataStruct.h"
|
||||
#include "OscReceiverActor.generated.h"
|
||||
|
||||
|
||||
UCLASS()
|
||||
class AOscReceiverActor : public AActor, public IOscReceiverInterface
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, Category=OSC)
|
||||
FString AddressFilter;
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=OSC)
|
||||
void OnOscReceived(const FName & Address, const FOscDataStruct & Data);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginDestroy() override;
|
||||
|
||||
virtual const FString & GetAddressFilter() override
|
||||
{
|
||||
return AddressFilter;
|
||||
}
|
||||
|
||||
virtual void SendEvent(const FName & Address, const FOscDataStruct & Data) override
|
||||
{
|
||||
OnOscReceived(Address, Data);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user