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"

PostInitProperties funcitonality for a USTRUCT

I'm trying to create a new BlueprintType with a USTRUCT. I expect to be able to do the following:

  • Make new variable in a blueprint (with my new type)

  • Set defaults for the new variable (in the blueprint)

  • The other members of the variable are initialized based on the specified defaults

Obviously I cannot use the PostInitProperties function in a struct since it is defined in UObject.

But if I change my struct to a class derived from UObject, I can't edit default values in the BP editor:

alt text

In other words, how do I remove the need for a custom initialization function? 99.9% of the time, it will be in this exact spot:

alt text

Or look at it this way:

In code alone, I'd just use parameters in the constructor to instantiate unique instances of a class/struct. How do I accomplish this with my C++ class when I am instantiating it in UE Blueprints?

I'd like to use it as a variable in Blueprints, so I don't want to have to create child Blueprint classes of my data class every time I simply need different defaults.

Is something like this possible, a feature request, or against UE4 standards/workflow?

Product Version: UE 4.19
init.png (15.0 kB)
more ▼

asked May 15 '18 at 07:46 AM in C++ Programming

avatar image

13 1 3 7

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

1 answer: sort voted first

I dont think that possible, default are stored in CBOs Class Defaults Object and struct is stored as a part of a class/object an both defaults and serialization in to the file, when you got PostInitProperties this includes all structs in the class.

You can create custom widget for property editor for your struct, maybe you could try doing something with that and leave constrcutor to do the work on C++ side:


Doing construction nodes is also valid solution but user can still normally make structs with make node

more ▼

answered May 15 '18 at 09:16 PM

avatar image

37.1k 935 172 1116

avatar image Ben0nator May 16 '18 at 03:01 AM

I'm not sure I understand. Could you elaborate on the two workarounds you mentioned? Concerning the first, I don't think I can add access to properties through UI customization?

(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