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"

FObjectFinder vs LoadObject

Let's collect the differences between the two methods, as they don't seem to be mentioned anywhere else.

  1. FObjectFinder is used in constructor, while LoadObject is used anywhere

  2. Syntax difference:

    
    UMaterial* material_var = LoadObject<UMaterial>(nullptr,TEXT("Material'/Game/...'"));
    //vs
    static ConstructorHelpers::FObjectFinder<UMaterial> material_wrapped(TEXT("Material'/Game/...'"));
    UMaterial* material_var = material_wrapped.Object;
    
  3. FObjectFinder creates a static var in C++ constructor which wastes sizeof(*ptr) of RAM per class for each time you use that method

I will add more differences as i discover them either myself or hear them here.
one particularly interesting is how slower is LoadObject compared to FObjectFinder?

Product Version: UE 4.19
Tags:
more ▼

asked Mar 18 '18 at 10:36 PM in C++ Programming

avatar image

Arty-McLabin
858 19 41 60

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

1 answer: sort voted first

I get an access violation error when using the FObjectFinder in the constructor of one class. Have you got any idea what the reason for that might be? The line is

 auto psAsset = ConstructorHelpers::FObjectFinder<UParticleSystem>(TEXT("ParticleSystem'/Game/ParticleSystems/PS_CompoundCloud_SingleCelled.PS_CompoundCloud_SingleCelled'"));


Thanks for the help.

more ▼

answered Jun 26 '18 at 10:28 AM

avatar image

GameAboutThings
3 1 1 4

avatar image Arty-McLabin Jun 29 '18 at 08:01 PM

are you getting the error when trying to reference psAsset later in code, or in this very line?

avatar image GameAboutThings Jun 29 '18 at 08:03 PM

In that exact line and if I try FObjectFinderOptional I get it on Succeeded() and Get()

avatar image Arty-McLabin Jun 29 '18 at 08:07 PM

sadly i don't have a clue on what could cause it. the only thing i would suggest is double checking you call it in the classic C++ MyClass() constructor, rather than OnConstruction()

otherwise i would submit a separate question here in AnswerHub

avatar image GameAboutThings Jun 29 '18 at 08:12 PM

I tried it in different constructors, in different classes. For some reason it only happens with particle systems. And I already posted a question two days ago and so far haven't got any answers so I thougt I might look around.

avatar image Arty-McLabin Jun 29 '18 at 08:39 PM

just keep bumping the question every 4-7 days. eventually you will get an answer. just please don't bump too much because it would be selfish :]

(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