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"

Templated USTRUCT?

Is there any way to use templates/generics on USTRUCT objects (or even UCLASS)?

For example, something like the following:

 USTRUCT(Blueprintable, Category = "Scripting|Remote Character|Attributes")
 template<typename Type>
 struct FRemoteCharacterSubAttribute
 {
     GENERATED_USTRUCT_BODY();
 public:
     FRemoteCharacterSubAttribute() {
         Name = FString(L"Unassigned");
         BaseCost = 0.0f;
     }
 
     UPROPERTY(BlueprintReadWrite, Category = "Scripting|Remote Character|Attributes")
     FString Name;
     UPROPERTY(BlueprintReadWrite, Category = "Scripting|Remote Character|Attributes")
     float BaseCost;
     UPROPERTY(BlueprintReadWrite, Category = "Scripting|Remote Character|Attributes")
     Type MinValue;
     UPROPERTY(BlueprintReadWrite, Category = "Scripting|Remote Character|Attributes")
     Type Value;
     UPROPERTY(BlueprintReadWrite, Category = "Scripting|Remote Character|Attributes")
     Type MaxValue;
 };

  

... And then you would use it like:

 USTRUCT(Blueprintable, Category = "Scripting|Remote Character|Attributes")
 struct FRemoteCharacterAttributes
 {
     GENERATED_USTRUCT_BODY();
 public:
     FRemoteCharacterAttributes() {
         fMovement.Name = FString("Movement");
         fMovement.BaseCost = 10.0f;
         fMovement.MinValue = 50.0f;
         fMovement.MaxValue = 500.0f;
         fMovement.Value = fMovement.MinValue;
     }
 
     UPROPERTY(BlueprintReadWrite, Category = "Scripting|Remote Character|Attributes")
     FRemoteCharacterSubAttribute<float> fMovement;
 };


  
  

Any way to make this happen?

Product Version: UE 4.11
Tags:
more ▼

asked Apr 13 '16 at 11:19 PM in C++ Programming

avatar image

MichaelWion
250 25 40 50

avatar image michal.buras Jul 18 '18 at 10:45 PM

Is there any change on the subject of templates ? Or any way to generate ustructs ?

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

1 answer: sort voted first

Hi Michael,

Template USTRUCTs, UCLASSES, UFUNCTIONs. etc. are not supported in any form, and are unlikely to be.

Steve

more ▼

answered Apr 14 '16 at 09:33 AM

avatar image

Steve Robb STAFF
2.8k 58 28 100

(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