UnrealCLR icon indicating copy to clipboard operation
UnrealCLR copied to clipboard

`UDataAsset` support

Open GMatrixGames opened this issue 2 years ago • 5 comments

Hey, I just wanted to ask if there was a way eventually to allow creation of Data Asset types in C# and use them like normal C++ classes.

It would make my life so much easier, but I understand if it's either hard to implement, or not possible.

Thanks

GMatrixGames avatar Jul 06 '21 01:07 GMatrixGames

Could you please provide a use case with sub-classes that you need from it?

nxrighthere avatar Jul 06 '21 12:07 nxrighthere

Hi, currently, this is an example of how it'd be used, you extend UPrimaryDataAsset or UDataAsset, have UPROPERTY(s) contained in it, and then also have methods included in it. It would just be easier than C++ having both a header and cpp file where you'd separate the method contents and UPROPERTY(s)

Attached is in C++ for visual representation image

GMatrixGames avatar Jul 06 '21 12:07 GMatrixGames

I'll look into this, but it sounds like you will also need https://github.com/nxrighthere/UnrealCLR/issues/61 for this.

nxrighthere avatar Jul 06 '21 12:07 nxrighthere

UDataAsset requires C++ code generation in order to make it work properly in the editor. Probably generation at runtime is possible, but the plugin doesn't have this feature at the moment. As the closest alternative, you can use UObject blueprint objects with properties and load them from C# at runtime.

nxrighthere avatar Jul 27 '21 14:07 nxrighthere

Just wanted to share our approach with C# Source Generators that we've prototyped.

celeronpm avatar Aug 03 '21 19:08 celeronpm