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"

Is there a way to get actual blueprint class from the Asset Registry?

When listing classes from the asset registry the 'Get Class' function returns 'Blueprint' or other basic asset types. I would like to get a class which can then be used to cast for a desired custom blueprint subclass. Is this possible in blueprint scripting?

Product Version: UE 4.17
Tags:
more ▼

asked Sep 09 '17 at 07:18 AM in Blueprint Scripting

avatar image

SwiftLeigh
31 3 4

avatar image Howie Oct 30 '17 at 04:51 PM

you ever find a solution to this, running into the same problem?

avatar image Wallby Oct 16 '18 at 09:07 AM

same here ;)

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Turns out it is quite easy to get the parent class of a blueprint asset. The asset registry will always return UBlueprint objects, but those objects themselves have a property ParentClass, which is the class that you're probably interested in. This class corresponds with the Native Parent Class that you can see when hovering over an asset in the editor.

alt text

For my purpose, I wanted to distinguish between inherited classes and the actual class itself too, which you can do using the IsChildOf method once you have the class you desire. In the snippet, Asset is of type FAssetData, and ClassType is a pointer to a UClass.

 const UBlueprint* BlueprintAsset = Cast<UBlueprint>(Asset.GetAsset());
 if (BlueprintAsset)
 {
     const bool IsClass = BlueprintAsset->ParentClass == ClassType;
     const bool IsChildClass = BlueprintAsset->ParentClass->IsChildOf(ClassType->StaticClass());
     if (IsClass || AllowInheritance && IsChildClass)
     {
         //...
     }
 }
more ▼

answered Oct 16 '18 at 01:49 PM

avatar image

Wallby
6 1 2

(comments are locked)
10|2000 characters needed characters left

I assume you want to cast to blueprint in C++, no you can not do that as it's technically impossible as class needs to exist in C++ to be valid C++ type. Everything gets compiled down to pure numbers, classes are practically just logical feature that only exists in compilation process and desolves in to machine code, so you can not use the class from blueprint.

You can only get UClass pointer from UBlueprint class via GeneratedClass variable and then use it to spawn actor for example, but you can only cast it to the most highest class that is in C++ and it's related to blueprint. I think (and thats just a guess) you could make node in blueprint in C++ by doing some hackish stuff in reflection system or (and this one for sure) by making new UK2Node.

more ▼

answered Oct 16 '18 at 10:30 AM

avatar image

Shadowriver
34.5k 917 164 1094

(comments are locked)
10|2000 characters needed characters left
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