任务1:利用多播委托实现同时控制场景中的多个灯光,PointLight类用蓝图实现
1、以Actor类为基类,创建MyTriggerBox类,在该类中声明多播委托FMultiDelegate,并实现该多播委托的触发;
MyTriggerBox.h代码如下:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyTriggerBox.generated.h"
//声明多播委托,带一个参数
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMultiDelegate, bool, bLightOn);
class UBoxComponent;
UCLASS()
class MULTIDELEGATE_API AMyTriggerBox : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyTriggerBox();
protected:
public:
UBoxComponent* TriggerBoxComp;
UPROPERTY(BlueprintAssignable,Category = "NPC_Delegate")
FMultiDelegate MyMultiDelegate;
//重写开始重叠和结束重叠函数
virtual void NotifyActorBeginOverlap(AActor* OtherActor) override;