zoukankan      html  css  js  c++  java
  • 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);
    
    }
  • 相关阅读:
    Jane Austen【简·奥斯汀】
    I Like for You to Be Still【我会一直喜欢你】
    Dialogue between Jack and Rose【jack 和 Rose的对话】
    git删除远程.idea目录
    码云初次导入项目(Idea)
    DelayQueue 订单限时支付实例
    eclipse安装spring的插件
    redis安装命令
    log4j详解
    jstree API
  • 原文地址:https://www.cnblogs.com/tilyougogannbare666/p/13452943.html
Copyright © 2011-2022 走看看