gpt4 book ai didi

c++ - 虚幻引擎 4 : Converting DrawMesh() from Unity

转载 作者:行者123 更新时间:2023-11-30 05:32:01 27 4
gpt4 key购买 nike

我是虚幻引擎 UE4 的新手,我想转换我现有的代码。有人可以帮忙吗?

Material material = Resources.Load ("Meshes/Materials/" + files [index] + "material_0", typeof(Material)) as Material;
Texture2D texture = Resources.Load ("Textures/" + files [index], typeof(Texture2D)) as Texture2D;
Mesh[] meshes = Resources.LoadAll ("Meshes/" + files [index], typeof(Mesh)).Cast<Mesh> ().ToArray ();
for (int m = 0; m < meshes.Length; m++) {
Graphics.DrawMesh (meshes [m], matrix, material, 0);
}

最佳答案

例如,此类代码必须放在类的构造函数中。此外,您还需要将 DefaultEditor.ini 中的 bDontLoadBlueprintOutsideEditor 设置为 false,因为如果它设置为 false,您的发布应用程序会因找不到蓝图类而崩溃。当然,您可以使用 GetMesh() 添加自定义 Material

static ConstructorHelpers::FObjectFinder<USkeletalMesh> AssignableMesh(TEXT("/Game/Units/Characters/UNT_Sol_01/UNT_Solder_01"));

static ConstructorHelpers::FObjectFinder<UPhysicsAsset> AssignablePhysics(TEXT("/Game/Units/Characters/UNT_Sol_01/UNT_Solder_01_PhysicsAsset"));

static ConstructorHelpers::FObjectFinder<UAnimBlueprint> AssignableABP(TEXT("/Game/Units/Characters/UNT_Sol_01/UNT_ABP"));

WeaponAttachment = AM4Weapon::StaticClass();

GetMesh()->bReceivesDecals = false;
GetMesh()->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::AlwaysTickPoseAndRefreshBones;
GetMesh()->SetSkeletalMesh(AssignableMesh.Object);
GetMesh()->SetRelativeRotation(FRotator(0.0f, -90.0f, 0.0f));
GetMesh()->SetRelativeLocation(FVector(0.0f, 0.0f, -100.0f));
GetMesh()->SetPhysicsAsset(AssignablePhysics.Object);
GetMesh()->SetAnimInstanceClass(AssignableABP.Object->GeneratedClass);
GetMesh()->SetRelativeScale3D(FVector(3.0f));

关于c++ - 虚幻引擎 4 : Converting DrawMesh() from Unity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35310327/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com