• 在UE4 C++构造函数里的常规操作


    1. 创建组件

      举个例子:

    .h:
        
        //根组件
        class USceneComponent* RootScene;
    
        UPROPERTY(VisibleDefaultsOnly, Category = "SlAi")
            class UStaticMeshComponent* BaseMesh;
    
    .cpp:
        
    //实例化根组件
        RootScene = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
        RootComponent = RootScene;
    
        //创建静态模型组件
        BaseMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BaseMesh"));
        BaseMesh->SetupAttachment(RootComponent);

    2. 在引擎里寻找内容

      举个例子:

        static ConstructorHelpers::FObjectFinder<USkeletalMesh> StaticMeshFirst(TEXT
        ("SkeletalMesh'/Game/Res/PolygonAdventure/Mannequin/FirstPlayer/SkMesh/FirstPlayer.FirstPlayer'"));
        MeshFirst = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MeshFirst"));
        MeshFirst->SetSkeletalMesh(StaticMeshFirst.Object);

    3. 在引擎里寻找蓝图

      举个例子:

    .cpp:
    //获取第一人称动作蓝图
        static ConstructorHelpers::FClassFinder<UAnimInstance> StaticAnimFirst(TEXT
        ("AnimBlueprint'/Game/BluePrint/Player/FirstPlayerAnimation.FirstPlayerAnimation_C'"));
        MeshFirst->AnimClass = StaticAnimFirst.Class;
  • 相关阅读:
    react 入坑笔记(五)
    练习
    高级指令
    进阶指令
    基础指令
    VMware 备份操作系统
    Ubuntu 用户的切换
    形态学转换
    图像模糊
    域名拆分 tld
  • 原文地址:https://www.cnblogs.com/mcomco/p/12427694.html
Copyright © 2020-2023  润新知