Unreal4 基础数据类型转换 int转FSting
2015-08-03 11:52
471 查看
Overview
FString to FNamestd::string to FString
FString and FCString Overview
FString to Integer
FString to Float
Float/Integer to FString
UE4 C++ Source Header References
All the header files I refer to in this tutorial are found in
your UE4 install directory / Engine / Source
you will probably want to do a search for them from this point :)
Converting FString to FNames
Say we haveFString TheString = "UE4_C++_IS_Awesome";
To convert this to an FName you do:
FName ConvertedFString = FName(*TheString);
std::string to FString
#include //.... some function { std::string TestString = "Happy"; FString HappyString(TestString.c_str()); }
FCString Overview
Converting FString to Numbers
The * operator on FStrings returns their TCHAR* data which is what FCString functions use.If you cant find the function you want in FStrings (UnrealString.h) then you should check out the FCString functions (CString.h)
I show how to convert from FString to FCString below:
Say we have
FString TheString = "123.021";
FString to Integer
int32 MyShinyNewInt = FCString::Atoi(*TheString);
FString to Float
float MyShinyNewFloat = FCString::Atof(*TheString);
Note that Atoi and Atof are static functions, so you use the syntax FCString::TheFunction to call it :)
Float/Integer to FString
FString NewString = FString::FromInt(YourInt); FString VeryCleanString =FString::SanitizeFloat(YourFloat);
Static functions in the UnrealString.h :)
UE4 Source Header References
CString.h UnrealString.h NameTypes.h
See CString.h for more details and other functions like
atoi64 (string to int64) Atod (string to double precision float)
For a great deal of helpful functions you will also want to look at
UnrealString.h for direct manipulation of FStrings!
For more info on FNames check out
NameTypes.h
Enjoy!
Rama (talk)
Category:
Code
相关文章推荐
- 生产者消费者模式
- C# I/O 助手类
- 7.1线程2015/8/2
- mysql查询更新时的锁表机制分析(只介绍了MYISAM)
- 网址收藏
- Shuffle'm Up---poj3087
- Wrong number of segments in token:
- 为Unreal4制作插件
- PHP程序员的技术成长规划
- Unreal4 IOS上使用第三方库和C++11 特性问题解决
- UnrealEngine4-Roadmap
- android知识图谱
- oracle 创建数据库时 Enterprise Manager 配置失败
- 算法速成(6)树操作
- WDS无线桥接
- Linux学习笔记05之IO重定向
- 浅谈优化程序性能(上)
- Unreal4 编译错误
- Unreal4 客户端编译.调试.与常见问题
- Convolutional Neural Networks (卷积神经网络)