代码问题。
请问这段蓝图写成代码要如何写呢?
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"));
}
那两个PickUpTexture连起来,请问是赋值的意思还是==的意思呢?感谢。
本帖最后由 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 );
}
mknmknmk 发表于 2017-12-7 09:10
AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)
这样的 ...
是要按照这样写吗? 我试过了,会报错,说不允许构造函数有参数 mknmknmk 发表于 2017-12-7 09:10
AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)
这样的 ...
我明白了,我发了这个求助之后,我把它删掉了,然后我在构造函数中按照蓝图的意思,写成这样FBag PickUpTezture = PickUpTexture ,可以编译通过,但是生成引擎的时候会崩溃,请问是什么原因呢? mknmknmk 发表于 2017-12-7 09:10
AMyActor::AMyActor(UTexture2D* PickUpTexture, class Actor* PickUpClass, FString PickUpName)
这样的 ...
回到家里电脑才看到您写的代码。。手机上看不到代码好奇怪的。。谢谢哈 不错不错
页:
[1]