UE5实现WidgetComponent点击事件-Screen与World兼容

大家都知道UE里边WidgetComponent的点击事件非常坑,没法响应UserWidget内部某个Button的点击,本文自定义了一个ClickableWidgetComponent,替换掉WidgetComponent即可实现UserWidget内部任意Button的点击,兼容Screen模式和World模式。

1、自定义 UClickableWidgetComponent.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/WidgetComponent.h"
#include "ClickableWidgetComponent.generated.h"

/**
 * 
 */
UCLASS(Blueprintable, ClassGroup="UserInterface", hidecategories=(Object,Activation,"Components|Activation",Sockets,Base,Lighting,LOD,Mesh), editinlinenew, meta=(BlueprintSpawnableComponent))
class PLANLOADER_API UClickableWidgetCompo

你可能感兴趣的:(UE4移动端Android,iOS入门,ue5,WidgetComponent,UserWidget,点击不响应)