[UE4]Level Native API Notes
keywords: [UE4]Level Native API Notes
How to let Level Blueprint inherit customized C++ class
-
New a C++ Actor which inheriting LevelScriptActor.
-
Open Level Blueprint, then click
Class Settings
, changeParent Class
. -
Then you can invoke the customized functions such as
UFUNCTION(BlueprintCallable)
which defined in yourLevelScriptActor
class.
参考:http://orfeasel.com/creating-a-c-level-blueprint/
How to get LevelScriptActor which an Actor stayed
if (ULevel* Level = MyActor->GetLevel())
{
if(ALevelScriptActor* LevelScriptActor = Level->GetLevelScriptActor())
{
if (AMyLevelScriptActor* LevelActor = Cast<AMyLevelScriptActor>(LevelScriptActor))
{
}
}
}
How to get Level name which an Actor stayed
FString LevelName = GetLevel()->GetOuter()->GetName();
Or:
FString LevelName = GWorld->GetLevel(0)->GetOuter()->GetName();
How to get world without WorldContextObject
Spawn actor in static function:
UWorld* World = GWorld->GetWorld();
World->SpawnActor(ActorClass);
天之道利而无害,人之道为而不争。 ----《道德经》