联机
PNG->Widget 1米==100PIX
调用EnableHMD节点或者执行stereo on/fullscreen进入VR模式
早期版本可调用Alt+Enter
BuildString FormatText
FString MyStr = TEXT("Hello, Unreal 4!").
FText MyText = NSLOCTEXT("Game UI", "Health Warning Message", "Low Health!")
// 在 GameUI.cpp 中
#define LOCTEXT_NAMESPACE "Game UI"
//...
FText MyText = LOCTEXT("Health Warning Message", "Low Health!")
//...
#undef LOCTEXT_NAMESPACE
// 文件末端
CString.h
UnrealString.h
NameTypes.h
Converting FString to FNames
FString TheString = "UE4_C++_IS_Awesome";
FName ConvertedFString = FName(*TheString);
std::string to FString
#include <string>
std::string TestString = "Happy";
FString HappyString(TestString.c_str());
FString to std::string
#include <string>
FString UE4Str = "Flowers";
std::string MyStdString(TCHAR_TO_UTF8(*UE4Str));
//You will find this particularly useful in cases other than float and int32!
//C++ std::String::to_string
//http://en.cppreference.com/w/cpp/string/basic_string/to_string
Converting FString to Numbers
//note Atoi is unsafe; no way to indicate errors
FString TheString = "123.021";
int32 MyShinyNewInt = FCString::Atoi(*TheString);
float MyShinyNewFloat = FCString::Atof(*TheString);
Float/Integer to FString
//Static functions in the UnrealString.h :)
FString NewString = FString::FromInt(YourInt);
FString VeryCleanString = FString::SanitizeFloat(YourFloat);
LOG
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, PlayerNameToDisplay);
UE_LOG(LogTemp, Warning, TEXT("Your message"));
函数接口
UFUNCTION(BlueprintPure, Category = "robslove")
UFUNCTION(BlueprintCallable, Category = "robslove")
变量接口
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "robslove")
GameMode
UWorld* const World = GetWorld();
AGameState* GameState = World->GetGameState();
const AVR_GameState* VRGameState = Cast<AVR_GameState>(GameState);
CreateDefaultSubobject / Destroy
class UBoxComponent* SpawnO = CreateDefaultSubobject<UBoxComponent>(TEXT("robslove"));
SpawnO->Destroy();
SpawnActor
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = Instigator;
FVector SpawnLocation;
FRotator SpawnRotation;
SpawnRotation.Yaw = FMath::FRand()*360.0f;
SpawnRotation.Pitch = FMath::FRand()*360.0f;
SpawnRotation.Roll = FMath::FRand()*360.0f;
ASpawnObject* const SpawnO = World->SpawnActor<ASpawnObject>(WhatToSpawn, SpawnLocation, SpawnRotation, SpawnParams);
GetAllActorsOfClass
TArray<AXXXActor> outActorts;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AXXXActor::StaticGetClass(), outActorts);
SetTimer
SpawnDelay = FMath::FRandRange(SpawnDelayRangeLow, SpawnDelayRangeHigh);
GetWorldTimerManager().SetTimer(SpawnTimer, this, &ASpawnVolume::SpawnO, SpawnDelay, false);
HiddenInGame主要控制编辑器里是否可见,参考(Box Collision)
//Allows us to only see this Actor in the Editor, and not in the actual game.
//@see SetActorHiddenInGame()
UPROPERTY(Interp, EditAnywhere, Category=Rendering, BlueprintReadOnly, replicated, meta=(DisplayName = "Actor Hidden In Game", SequencerTrackClass = "MovieSceneVisibilityTrack"))
uint8 bHidden:1;
//Whether to completely draw the primitive; if false, the primitive is not drawn, does not cast a shadow.
UPROPERTY(EditAnywhere, BlueprintReadOnly, ReplicatedUsing=OnRep_Visibility, Category = Rendering)
uint32 bVisible:1;
//Whether to hide the primitive in game, if the primitive is Visible. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Rendering)
uint32 bHiddenInGame:1;
相機切換
// 立即切换到相机1
OurPlayerController->SetViewTarget(CameraOne);
// 平滑地混合到相机2。
OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
==========================================================
U3D
C#
this.transform.FindChild("Sphere").GetComponent<Renderer>().material.color = Color.red;
JS:
transform.FindChild("Sphere").GetComponent.<Renderer>().material.color = Color.red;