Announcement

Collapse
No announcement yet.

Confusion about path argument in FObjectFinder

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Confusion about path argument in FObjectFinder

    I'm trying to give my character class a skeletal mesh but am unclear how FObjectFinder works. I have 2 questions.

    1) What should the path argument be, and what is it relative to?
    For instance -
    Code:
    // Absolute path to asset file 
    E:/Unreal/Projects/FPSProject/Content/Models/SK_Mannequin.uasset
    
    // Absolute path to class .cpp source file 
    E:/Unreal/Projects/FPSProject/Source/FPSProject/FPSCharacter.cpp

    If I make this call from FPSCharacter.cpp ...
    Code:
    static ConstructorHelpers::FObjectFinder<USkeletalMesh> 
            NewMesh(TEXT("/FPSProject/Content/Models/SK_Mannequin.uasset"));
    ... Will the directory "/FPSProject" be evaluated as
    Code:
    E:/Unreal/Projects/FPSProject/Source/FPSProject/
    
    or 
    
    E:/Unreal/Projects/FPSProject/


    2) What is the prefix of the path in FObjectFinder's argument?
    In the following code, the argument is "StaticMesh'/Game/StarterContent/Props/MaterialSphere.MaterialSphere'"
    What is "StaticMesh" in that argument?
    Code:
    static ConstructorHelpers::FObjectFinder<UStaticMesh>
    BaseMeshAsset(TEXT("StaticMesh'/Game/StarterContent/Props/MaterialSphere.MaterialSphere'"));
    Is it a class type, a file name, a directory?
    What happens if you exclude it?



    I've been stuck on this for a while, so any help would be appreciated.
    Also any examples and explanations of how to use FObjectFinder, and how it works, would be very helpful.

    Thanks!

    #2
    The path is relative to your (or the engines, or a plugins) content folder. For example:
    /Game/Folder/Asset.Asset will be /Project/Content/Folder/Asset.uasset on disk.
    /Engine/Folder/Asset.Asset will be /Engine/Content/Folder/Asset.uasset on disk.
    /PluginName/Folder/Asset.Asset will be something like /Engine/Plugins/PluginName/Content/Folder/Asset.uasset.

    If you're wondering about the Asset.Asset thing, that's because you're loading a uasset package called Asset and then the object that is also called Asset from that. Pretty much the only time you need to change this convention is when loading a blueprint, where you need Asset.Asset_C to get the generated class object.

    The "prefix" lets you filter what type of object to load. It is more of a relict and not particularly useful, since you're already filtering by class when loading things. I'd just leave it out.

    Going back to your example, the path you want is "/Game/Models/SK_Mannequin.SK_Mannequin"

    Comment


      #3
      All our code is like this:

      Code:
      const FString CROSSHAIR_TEXTURE = "/Game/Textures/Icons/CrossHairAimPoint.CrossHairAimPoint";
       _textureCrossHair = ConstructorHelpers::FObjectFinder<UTexture2D>(*CROSSHAIR_TEXTURE).Object;

      Comment

      Working...
      X