UE4源码摘录(424)

https://docs.unrealengine.com/en-US/Programming/Introduction/index.html

UE4 prefix:

  • Classes derived from Actor prefixed with A, such as AController.

  • Classes derived from Object are prefixed with U, such as UComponent.

  • Enums are prefixed with E, such as EFortificationType.

  • Interface classes are usually prefixed with I, such as IAbilitySystemInterface.

  • Template classes are prefixed by T, such as TArray.

  • Classes that derive from SWidget (Slate UI) are prefixed by S, such as SButton.

  • Everything else is prefixed by the letter F , such as FVector.

Letter F:

This gets asked all the time and I thought I would share the official story, as I remember wondering the same thing.

'U' stands for UObject, 'A' stands for actor, 'T' stands for Template. Everyone gets that. But what does 'F' stand for? It's used almost everywhere else!

The 'F' prefix actually stands for "Float" (as in Floating Point.)

Tim Sweeney wrote the original "FVector" class along with many of the original math classes, and the 'F' prefix was useful to distinguish from math constructs that would support either integers or doubles, even before such classes were written. Much of the engine code dealt with floating point values, so the pattern spread quickly to other new engine classes at the time, then eventually became standard everywhere.

This was in the mid-nineties sometime. Even though most of Unreal Engine has been rewritten a few times over since then, some of the original math classes still resemble their Unreal 1 counterparts, and certain idioms remain part of Epic's coding standard today.

Just a quick and fun story about Unreal's history I thought I'd share.


--Mike

 

创建对象方法(转载:https://blog.csdn.net/luofeixiongsix/article/details/81061764 )

Actor:

UWorld* World = GetWorld();  
FVector pos(150, 0, 20);  
 //生成Actor
AMyActor* MyActor = World->SpawnActor<AMyActor>(pos, FRotator::ZeroRotator);
//创建Component
MyComponent = CreateDefaultSubobject<UMyActorComponent>(TEXT("MyComponent"));

//加载资源对象
UStaticMesh* SM_Vase = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT("/Game/Assets/StaticMeshes/SM_Vase")) ); StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComponent")); StaticMeshComponent->SetStaticMesh(SM_Vase);

//创建UObject
MyObject = NewObject<UMyObject>();

  

UE4 Commandlet:

execute project:

"D:\UE_4.24\Engine\Binaries\Win64\UE4Editor-Cmd.exe" "D:\UE_Proj\Proj424\MyProject2\MyProject2.uproject" 

注意引号

 

 

ContentBrowser import:

 

SContentBrowser.cpp 1005

FReply SContentBrowser::HandleImportClicked()
{
    ImportAsset( GetCurrentPath() );
    return FReply::Handled();
}
void SContentBrowser::ImportAsset( const FString& InPath )
{
	if ( ensure( !InPath.IsEmpty() ) )
	{
		FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>( "AssetTools" );
		AssetToolsModule.Get().ImportAssetsWithDialog( InPath );
	}
}
posted @ 2020-07-08 14:03  Cullchestar  阅读(286)  评论(0编辑  收藏  举报