Unreal Cook Book: Data-driven

Source: Internet
Author: User

In the game development often need to use data-driven, commonly known as "Planning pull table." In the Unreal 4 engine, there are several ways to process data, and here I introduce two of the most common ones.

Unreal Engine built-in table import mechanism

Suppose the planner has the following data sheet for storing information about props:

Price
Name Damage Desc
Shanker 707 6395 warmongering Gladiator ' s Shanker
Ripper 814 6400 Tournament Gladiator ' s Ripper
Chopper 407 3976 warmongering Combatant ' s Chopper

To import this data table, you first need to define a data structure that corresponds to the structure of the table. If you use C + + programming, you need to create a ftablerowbase derived class, and if you use Blueprint, you can create a standard struct. Is the blueprint Struct I created for this table.

Then, the above table needs to be stored in CSV format. You can then drag and drop the CSV file into the content browser of the engine. In the data import settings, set the data type to our structure: itemdef.

Finally, we can use the two blueprint nodes of Getdatatablerownames and Getdatatablerow to read this tabular data. The specific blueprint is as follows:

If you can't see the picture, please download the project file. :)

Unreal Engine's Dataasset

Another common requirement is that we need to edit some commonly used data objects in the engine editor, which do not require bulk configuration, but need to be easily and flexibly modified. ScriptObject is provided in the Unity3d to do this kind of thing, but in Unreal 4, the Dataasset is the same, and the same is true of the way it is used.
First we need to create a Udataasset derived class that uses this class to manage a set of data:

/** * 演示使用DataAsset来处理数据 */UCLASS(Blueprintable, Category="DataDemo"public UDataAsset{    GENERATED_BODY()public:    UPROPERTY"DataDemo")    FString QuestSetName;    "DataDemo")    TArray<FQuestDef> QuestArray;};

With this class, in the Content browser new asset menu –> miscellaneous inside the Select "Dataasset", will pop up the following window, the window has more of our class:


-Once you have created this dataasset, you can edit it with the built-in editor of the engine:

    • Once edited, we can use the Loadasset node in blueprint to load it:
Project files & source code download

Source code Download: Https://code.csdn.net/neil3d/unrealcookbook
Demo Run: Content/datademo/datademomap

Related Official documents: https://docs.unrealengine.com/latest/INT/Gameplay/DataDriven/

Unreal Cook Book: Data-driven

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.