Skip to content

UE_5.5.4 BlueprintNativeEvent 无法从c++ call Lua #751

@zurui-hub

Description

@zurui-hub
UFUNCTION(BlueprintImplementableEvent)
void MyFuntion();

// Begin Class UMyClass Function MyFuntion
static const FName NAME_UMyClass_MyFuntion = FName(TEXT("MyFuntion"));
void UMyClass::MyFuntion() const
{
	UFunction* Func = FindFunctionChecked(NAME_UMyClass_MyFuntion);
	// 5.5生成的代码相比5.3多了下面这行CLASS_Native,导致调用不到ProcessEvent
	if (!Func->GetOwnerClass()->HasAnyClassFlags(CLASS_Native)) 
	{
		const_cast<UMyClass*>(this)->ProcessEvent(Func,NULL);
	}
	else
	{
		const_cast<UMyClass*>(this)->MyFuntion_Implementation();
	}
}

//5.3
static FName NAME_UMyClass_MyFuntion = FName(TEXT("MyFuntion"));
void UMyClass::MyFuntion() const
{
	const_cast<UMyClass*>(this)->ProcessEvent(FindFunctionChecked(NAME_UMyClass_MyFuntion),NULL);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions