Embedded resource pointers not working in napkin


#1

If I declare a property of type ResourcePtr, where T is derived from Resource and defined in RTTI, and declare this property as EPropertyMetaData::Embedded it is not possible to assign a value to the resource pointer in napkin. This forces the user to declare resources always in the root of the resources list and assign them to properties in a non-embedded way, making the EPropertyMetaData::Embedded flag of no much use really, which is a pity.
This is remarkable, because adding ResourcePtr values to an embedded property of type vector<ResourcePtr> works fine.

See also:


#2

Looks like we didn’t have any occurrences of this situation before, hence the lack of support.
Currently, the editor assumes that object exists and will show its properties.
For vectors, it makes sense to start off with an empty list and add elements, but for single pointers this seems a little ambiguous:

  • Should the user manually have to create an instance using the editor? Or in other words: does it ever make sense to have a null value for this pointer?

or

  • Should the editor auto-create all single embedded objects when a new object is created? (in this case one of course)

I feel the latter makes more sense because why would you want an “embedded null value”.
What do you think?

It should not be hard to add support for either solution.


#3

Hi Bas!

It should for sure be the former one imho (a humble opinion for sure :smiley: )

Should the user manually have to create an instance using the editor? Or in other words: does it ever make sense to have a null value for this pointer?

Yes because often the embedded object is polymorphic and you want the user to be able to choose the type! So start with a null value and have the user create it.


#4

Auto creation is indeed dangerous when working with polymorphic objects. But to me an embedded single pointer is rather useless unless you have many objects that required a reference. What would be the preferred work-flow here? Right click on the field and select ‘create’?


#5

My case is that I have a whole family of AudioObjects that generate audio and that can be nested, and I need to be able to wrap these in a component. So I have an AudioComponent which embeds an AudioObject. This object can be any type derived form AudioObject.
Right click on the field, select ‘create’ and select from a list of all types derived from the type T wrapped in the ResourcePtr would do.


#6

Your argument for polymorphism makes sense.
I’ll add the feature similar to adding elements to an array.


#7

Implemented the feature, awaiting review :smiley:


#8

reviewed and merged, thanks @bas


#9

Great! It’s really useful.