UE4 笔记

 

联机


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;

 

 

 

转载于:https://my.oschina.net/robslove/blog/783838

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值