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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Reading variable from User Defined Struct in c++

I made Structure in Unreal's interface and referenced it with "UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Animations) class UStruct* Struct_Animations;" in header. (and assigned it from within Unreal) Now, how can I access one of the variables from that struct in some function in .cpp? It's a beginner's question, I know, but I just don't know where to look for an answer.

Product Version: UE 4.18
Tags:
more ▼

asked Mar 22 '18 at 06:47 PM in C++ Programming

avatar image

Iletic
6 1 2 2

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

1 answer: sort voted first

First of all UStruct contains type of stuct not struct it self same as UClass. You would need to read property of the UClass of blueprint and then read the struct data using UStructProperty and read it off properties same way you do from class, here example of reading properties over here:

https://answers.unrealengine.com/questions/161741/accessing-blueprint-variables-through-c.html

Or you can do it a lot easier way.... just delere struct in C++, then you can easily keep it in varable in C++ and use it as Blueprint struct in in same time (BlueprintType makes struct usable in blueprints as a type)

 USTRUCT(BlueprintType)
 struct FMyStruct {
 
        GENERATED_BODY()
 
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Something")
        int32 MyInt;
 
        //more properties here
 }

and then just make varable

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Animations) 
 FMyStruct Struct_Animations;


more ▼

answered Mar 22 '18 at 09:09 PM

avatar image

Shadowriver
36.5k 930 169 1111

avatar image Iletic Mar 22 '18 at 09:19 PM

This is so much better. Thanks!

(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