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"

String Formatting for TEXT

What I want to do is easy but I cannot figure it out.

 static ConstructorHelpers::FObjectFinder<UStaticMesh> GroundShape(TEXT("StaticMesh'/Game/Shapes/Ground/ground_shape_1.ground_shape_1'"));

The code above is the think I want to achieve. However, it is going to be a dynamic version of it. For instance rather than ground_shape_1, I want the number 1 to be non-static. I want version like ground_shape_1, ground_shape_2, ground_shape_3 and so on. However, I do not know how to format a TEXT.

 FString::Printf(TEXT("StaticMesh'/Game/Shapes/Ground/ground_shape_%d.ground_shape_%d'"), i);   

The code above looks fine but FObjectFinder just does not want FString but TChar only.

Any Suggestions?

Product Version: Not Selected
more ▼

asked Aug 10 '14 at 09:37 PM in C++ Programming

avatar image

245 36 37 169

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

1 answer: sort voted first

The dereference operator (*) is overloaded on FString to return a pointer to its internal TCHAR buffer.

This should sort you out:

 *FString::Printf(TEXT("StaticMesh'/Game/Shapes/Ground/ground_shape_%d.ground_shape_%d'"), i);
more ▼

answered Aug 10 '14 at 09:40 PM

avatar image

Jamie Dale STAFF
7.4k 176 66 304

avatar image ErayT Aug 10 '14 at 09:48 PM

Thank you sir. I need to improve my C++ skills.

avatar image Jamie Dale STAFF Aug 10 '14 at 09:51 PM

Oh, that one's a Unreal Engine oddity :)

I've never seen another string class that does that (you usually either have to call a function to get the buffer, or they overload the cast operator to allow it to happen implicitly).

(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