代码问题。

[复制链接]
查看2567 | 回复5 | 2017-12-6 17:41:16 | 显示全部楼层 |阅读模式
L6~_LG}IGQBS$K167Y7)[@L.png
请问这段蓝图写成代码要如何写呢?

[mw_shl_code=cpp,false]AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)
{
        // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
        PrimaryActorTick.bCanEverTick = true;

        PickUpTexture = PickUpTexture;
        PickUpClass =
        PickUpName = PickUpName;

        PickUpMesh = CreateDefaultSubobject<UStaticMeshComponent>(FName("PickUpMesh1"));

}[/mw_shl_code]

那两个PickUpTexture连起来,请问是赋值的意思还是==的意思呢?感谢。
mknmknmk | 2017-12-7 09:10:46 | 显示全部楼层
本帖最后由 mknmknmk 于 2017-12-7 09:55 编辑

AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)

这样的构造函数不允许

应该这样写
UCLASS()
class RMC_EXAMPLES_API ARuntimeMeshObjectBase : public AActor
{
        GENERATED_BODY()
       
public:       

        UPROPERTY(EditAnywhere)
        URuntimeMeshComponent* RuntimeMesh;
       
        // Sets default values for this actor's properties
        ARuntimeMeshObjectBase();

        // Called when the game starts or when spawned
        virtual void BeginPlay() override;
       
        // Called every frame
        virtual void Tick( float DeltaSeconds ) override;

};

ARuntimeMeshObjectBase::ARuntimeMeshObjectBase()
{
        // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
        PrimaryActorTick.bCanEverTick = true;


        RuntimeMesh = CreateDefaultSubobject<URuntimeMeshComponent>(TEXT("Runtime Mesh"));
        RootComponent = RuntimeMesh;
}

// Called when the game starts or when spawned
void ARuntimeMeshObjectBase::BeginPlay()
{
        Super::BeginPlay();
       
}

// Called every frame
void ARuntimeMeshObjectBase::Tick( float DeltaTime )
{
        Super::Tick( DeltaTime );

}

回复 支持 反对

使用道具 举报

天天爱学习 | 2017-12-7 09:31:46 | 显示全部楼层
mknmknmk 发表于 2017-12-7 09:10
AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)

这样的 ...

是要按照这样写吗? 我试过了,会报错,说不允许构造函数有参数
回复 支持 反对

使用道具 举报

天天爱学习 | 2017-12-7 09:34:47 | 显示全部楼层
mknmknmk 发表于 2017-12-7 09:10
AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)

这样的 ...

我明白了,我发了这个求助之后,我把它删掉了,然后我在构造函数中按照蓝图的意思,写成这样FBag PickUpTezture = PickUpTexture ,可以编译通过,但是生成引擎的时候会崩溃,请问是什么原因呢?
回复 支持 反对

使用道具 举报

天天爱学习 | 2017-12-7 18:04:00 | 显示全部楼层
mknmknmk 发表于 2017-12-7 09:10
AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)

这样的 ...

回到家里电脑才看到您写的代码。。手机上看不到代码好奇怪的。。谢谢哈
回复 支持 反对

使用道具 举报

wxb35 | 2017-12-17 13:40:08 | 显示全部楼层
不错不错   
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

12

主题

34

回帖

41

积分

初始化成员

积分
41