x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

独自クラスの作成について

下記のように独自クラスを作るという書き方をして、その後、testクラスの中のx変数をブループリントに公開して操作したいのですが、エラーばかり出てしまい、出来ません。 そもそも、このような書き方は間違っているのでしょうか?


//UCLASS()をつけたいが、
// Error: Invalid class name 'test'. The class name must have an appropriate prefix added (A for Actors, U for other classes).が発生してしまう。
class MYPROJECT_API test
{
public:
    test();
    ~test();
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Simulation")
    int x;
    UFUNCTION(BlueprintCallable, Category = "Simulation")
    void run();
};
UCLASS(Blueprintable , BlueprintType)
class AMyGameMode : public AGameModeBase
{
    GENERATED_BODY()
public:
    AMyGameMode();
    virtual void BeginPlay() override;
    virtual void Tick(float DeltaTime) override;
    //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Simulation")をつけたいが
    // Unrecognized type 'test' - type must be a UCLASS, USTRUCT or UENUM が発生してしまう
    test s;
    // 問題なし
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Simulation")
    int32 aa;
};

Product Version: UE 4.19
Tags:
more ▼

asked Apr 10 '18 at 10:52 AM in Japanese

avatar image

cmd_testkusa
7 2 2 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

まずはエラー内容で指摘されている内容を満たすべきかと思います
エラー文を和訳しておきますので参考にしてください

エラー:無効なクラス名'test'。クラス名は適切なプレフィックスを付ける必要があります(ActorならA、その他のクラスならU)

more ▼

answered Apr 10 '18 at 11:57 AM

avatar image

T_Sumisaki
4.5k 31 4 8

avatar image cmd_testkusa Apr 10 '18 at 11:20 PM

ありがとうございます。 一応、できるようになりました。 ちょっと触ってて追加で質問したいことができましたが、それは別の質問スレで行いたいと思います。


UCLASS()
class MYPROJECT_API Utest : public UObject
{
    GENERATED_BODY()
public:
    Utest();
    ~Utest();
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Simulation")
    int x;
    UFUNCTION(BlueprintCallable, Category = "Simulation")
    void run();
};
UCLASS(Blueprintable , BlueprintType)
class AMyGameMode : public AGameModeBase
{
    GENERATED_BODY()
public:
    AMyGameMode();
    virtual void BeginPlay() override;
    virtual void Tick(float DeltaTime) override;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Simulation")
    Utest *s;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Simulation")
    int32 aa;
};

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question