[UE4]C++实现动态加载UObject:StaticLoadObject();以Texture和Material为例
来源:互联网 发布:淘宝网上哪家玉好 编辑:程序博客网 时间:2024/06/08 05:37
http://aigo.iteye.com/blog/2268056
相关内容:
C++实现动态加载的问题:LoadClass<T>()和LoadObject<T>()
http://aigo.iteye.com/blog/2281558
C++静态加载问题:ConstructorHelpers::FClassFinder()和FObjectFinder()
http://aigo.iteye.com/blog/2281373
示例1:
动态加载Object的工具方法
- UTexture2D* MyTextureLoader::LoadTextureFromPath(const FString& Path)
- {
- if (Path.IsEmpty()) return NULL;
- return Cast<UTexture2D>(StaticLoadObject(UTexture2D::StaticClass(), NULL, *(Path)));
- }
调用:
- FString PathToLoad = "/Game/Textures/YourStructureHere";
- UTexture2D* tmpTexture = LoadTextureFromPath(PathToLoad);
示例2:
加载Material和Texture
- struct FConstructorStatics
- {
- ConstructorHelpers::FObjectFinderOptional<UTexture> TextureFinder;
- ConstructorHelpers::FObjectFinderOptional<UMaterial> MaterialFinder;
- FConstructorStatics()
- : TextureFinder(TEXT("Texture2D'/Game/Textures/2DBackground.2DBackground'"))
- , MaterialFinder(TEXT("Material'/Game/Materials/DynamicTextureMaterial.DynamicTextureMaterial'"))
- {
- }
- };
- static FConstructorStatics ConstructorStatics;
- Texture = ConstructorStatics.TextureFinder.Get();
- UMaterial* Material = ConstructorStatics.MaterialFinder.Get();
- DynamicMaterial = UMaterialInstanceDynamic::Create(Material, this);
设置调用加载好的Material和Texture:
- DynamicMaterial->SetTextureParameterValue(FName("DynamicTexture"), Texture);
- Mesh->SetMaterial(0, DynamicMaterial);
如果资源永不再使用,想销毁资源对象,代码如下:
- Texture2D* mytex; //这里假设mytex合法有效
- mytex->ConditionalBeginDestroy();
- mytex = NULL;
- GetWorld()->ForceGarbageCollection(true);
Dynamic Asset Loading with C++
https://www.youtube.com/watch?v=pJIAmSGxfmQ
Dynamic Load Object
https://wiki.unrealengine.com/Dynamic_Load_Object
阅读全文
0 0
- [UE4]C++实现动态加载UObject:StaticLoadObject();以Texture和Material为例
- UE4中StaticLoadClass和StaticLoadObject
- 以GIF为背景加载图片实现动态倒计时
- [UE4]C++实现动态加载的问题
- 动态加载表格(以乘法口诀为例)
- [UE4]C++实现动态加载的问题:LoadClass<T>()和LoadObject<T>()
- [UE4]C++实现动态加载的问题:LoadClass<T>()和LoadObject<T>()
- ue4中的继承自UObject的类实现每帧Tick
- 后期材质(PostProcess Material)+ Custom Node 实现"描边"和"马赛克"效果【UE4】
- NGUI动态加载图片创建Texture
- UE4 Texture Properties
- UE4 Texture Streaming
- c语言用宏实现模板-以队列为例
- c语言用宏实现模板-以队列为例
- Texture(纹理)和Material(材质)概念上的区别
- map、mesh、texture、material 和 shader 的联系
- Texture & Map & Material
- 【python爬虫】动态加载页面的解决办法(以ins为例)
- python使用webdriver爬取微信公众号信息
- 抓取线程状态
- Spring MVC和Struts2的比较的优点
- 用@ExceptionHandler 来进行异常处理
- 嵌入式软件工程师经典笔试题
- [UE4]C++实现动态加载UObject:StaticLoadObject();以Texture和Material为例
- rocket mq 时间表示例——setDelayTimeLevel
- this的用法 – JavaScript深入浅出(二)
- Linux程序设计实践
- (转载)Linux 学习记录 四(Bash 和 Shell scirpt)
- java核心技术卷 之布局管理概述
- SpringMVC(一)注解
- eclipse中的web项目导入到myeclipse中
- 英语单词复数到底读s还是z?