• UE4C++(1)添加组件


    这个是.h里的代码

    #pragma once
    
    #include "CoreMinimal.h"
    #include "GameFramework/Pawn.h"
    #include "Components/StaticMeshComponent.h"
    #include "SphareBase.generated.h"
    
    UCLASS()
    class TEXTGAME_API ASphareBase : public APawn
    {
        GENERATED_BODY()
    
    public:
        // Sets default values for this pawn's properties
        ASphareBase();
            //添加组件,设置宏为引擎到处可编辑,蓝图改写没问题
        UPROPERTY(EditAnywhere, BlueprintReadWrite)
            UStaticMeshComponent * SphereMesh;
    
    
    protected:
        // Called when the game starts or when spawned
        virtual void BeginPlay() override;
    
    public:    
        // Called every frame
        virtual void Tick(float DeltaTime) override;
    
        // Called to bind functionality to input
        virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
    
    };

    这个是.cpp里面的代码

    #include "SphareBase.h"
    
    // Sets default values
    ASphareBase::ASphareBase()
    {
         // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
        PrimaryActorTick.bCanEverTick = true;
    
        SphereMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SphereBase"));//创建组件方法
        SphereMesh->SetSimulatePhysics(true);//设置物理属性开启
    }
    
    // Called when the game starts or when spawned
    void ASphareBase::BeginPlay()
    {
        Super::BeginPlay();
        
    }
    
    // Called every frame
    void ASphareBase::Tick(float DeltaTime)
    {
        Super::Tick(DeltaTime);
    
    }
    
    // Called to bind functionality to input
    void ASphareBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
    {
        Super::SetupPlayerInputComponent(PlayerInputComponent);
    
    }
  • 相关阅读:
    Kubernets 第一讲 初探
    docker 运行nginx并进入容器内部、端口映射
    Docker 国内镜像的配置及使用
    Centos7上安装docker
    富文本编辑器--FCKEditor 上传图片
    在centos7上安装elasticSearch
    Centos7上卸载openJdk安装,安装自己的JDK1.8
    fastdfs 上传图片 完整版
    nginx 启动报错 “/var/run/nginx/nginx.pid" failed” 解决方法
    nginx + fastdfs 的开机自启动
  • 原文地址:https://www.cnblogs.com/tilyougogannbare666/p/13452943.html
Copyright © 2020-2023  润新知