UDataAsset - Data Assets in Unreal C++ - Data Instances and Data Classes - UE C++ Tutorial

preview_player
Показать описание
This video covers the information you need to know about data assets from a c++ perspective.
The C++ capabilities, and how blueprints interact with code data assets.

I think of things in terms of data instances and data (sub)classes.
When you subclass UDataAsset, you're creating a new type of data class.
Your new subclass can be used to create data instances, where designers will populate the variables on your data class.
Data instances are atomic units of data, and do not support inheritance.
No data inheritance on data instances is actually a feature.
In my opinion, the lack of data inheritance makes these data assets easily to maintain.
You cannot have your data asset corrupted, because something changed in the parent.

If you need to modify multiple asset values, the property matrix editor is a good solution.
Select all the assets that need data updating (hint, you can go to root of content broswer and search to find multiple folders to select all at once)
Right click on one, go to asset actions, and then "edit selection in property matrix"
And now you can update multiple assets at the same time.

When refactoring, you can change a data instance's type to upgrade it.
You can right click a data instance in the content browser, and an option to convert the data asset type will be available.

Note that this does not cover primary data assets, which I plan to cover later.
Primary data assets are an extension of UDataAsset, and I think you should understand all the content in this video before moving on to Primary Data Assets.

0:00 Video Preview Summary (Quick Reference)
2:23 Video Start
2:28 DataAsset: Subclassing UDataAsset in code to make a data class
2:47 DataAsset: Setting up a data property
3:43 Spawner: Making a spawner actor that uses the data asset
4:05 Spawner: data asset instance reference
5:10 Spawner: Overlap spawning logic
6:41 DataAsset: Data asset instances are singletons
7:02 CPP: including files for data assets
8:05 Visual Actor: making the visual sphere actors in editor (actors to spawn via spawners)
8:36 DataAsset: Making the data asset instances in editor
9:10 Spawner: Making the spawner in editor
9:47 Level: Placing spawners in the level
9:53 Testing spawning: using the spawners
10:05 Pointer Addresses: Evidence data asset instances are shared memory
11:06 Constness: Prefer const data asset pointers
11:20 Level: Mores spawners with different data! Specified by level instances!
11:54 Data Instance vs Data Class (ie Data Subclass)
12:29 Making a Data Class in blueprint instead of code (code must opt-in to allowing this)
14:14 Making a data instance from a blueprint data class
14:50 Data Asset Casting: Making a specialized spawner that uses the blueprint extended data class
15:42 Level: Testing the customized blueprint spawners
17:00 Code Data Subclasses: Code subclassing of data assets to make new data classes.
17:27 Refactoring: changing data asset types (convert data asset)
17:40 Testing code data subclass
18:07 Data inheritance is not allowed for data instances. Data instances are explicitly specified atomic units units of data.
18:51 Bonus Tip: Efficiently modifying multiple assets (property matrix view)
20:10 Closing Summary
20:54 Outro
Рекомендации по теме
Комментарии
Автор

Another video LOADED with detailed info that you usually don't see anywhere else! Thanks a lot for making these videos!!

peacesells
Автор

Yet another quality video. Can't believe this channel is not wildly popular at this point. I've been working / using UDataAssets for quite a while and still I learned lots of useful stuff from your video.
IIRC last time you mentioned that you have already couple of videos in production pipeline, I wonder if there are any plans for video about UPrimaryDataAsset, soft object references or asset manager? There are a couple of videos about these but none really demonstrates when to use them, what practical problems they solve and general good practices ralated.

maciekgadek
Автор

Hello, thanks for a beautiful explanation, it's very high quality material!
I have a question. My code architecture is currently based on those DataAssets .. let's say I have monstersDA, and I am sometimes updating their values like HP, status, etc - which then reflects on the UI widgets which are taking values from these Data Assets. Is this a wrong architecture? What's wrong on modifying these DataAssets - if they represents an entity (actor) within the game? What's your thought on this, or what would you recommend doing instead? Thanks a lot for the help!

GfxWakeup
Автор

I have a request that might be related. Could you do a tutorial on how the UObjectHandle class work? I have experience with exceptions the handles throw. I just feel now that Unreal is going towards TObjectPtr which are wrappers to the raw pointers, an understanding on how these handles work for caching or lazy loading purposes might come in handy when debugging issues that arise from them.

staticjpl
Автор

Say I create a C++ data asset. I create a BP instance of this asset. Designers modify the blueprint instance and give it some values. What's the best way to access those values from C++? My current approach is to give the data asset class a primary asset ID (or just make it UPrimaryAsset), then setup the primary asset in Project Settings > Asset Manager. Then from the cpp side I can use the asset ID + AssetManager to get the path of the primary asset and load. Is there a better way?

GlassesAndCoffeeMugs
Автор

Can't find how to make an inherited from PDA data asset instance directly in C++ if multiple inheritance is forbidden. Using cast?

PsijicV
Автор

Think it would be helpful to some if you expanded on why you would use Data Assets over Data Tables and maybe go into ASync Loading / Asset Manager / Querying Meta Data features.

shannenmr
Автор

although your videos are amazing, why are you asking the viewer to watch it at a faster speed? i'm asking because I feel like initial speed of the video is aleady perfectly appropriate.

l_t_m_f
welcome to shbcf.ru