Unable to add AudioObject to AudioComponent


#1

Hi,

I am unable to set the “Object” property of a nap::audio::AudioComponent in Napkin. A ‘Create…’ or ‘Add…’ option is not showing up:

Also, an AudioComponent defined manually in json like this…:

            {
                "Type": "nap::audio::AudioComponent",
                "mID": "externalInput",
                "Object": {
                    "Type": "nap::audio::Input",
                    "mID": "nap::audio::Input",
                    "Channels": [
                        0,
                        0
                    ]
                },
                "Links": []
            }

…shows up like this in Napkin:

(note that the type of the Object is still AudioObject*, instead of Input)


Embedded resource pointers not working in napkin
#2

Just tested this and ran into it too. Just to clarify: The “Object” property in AudioComponent is a ResourcePtr to an AudioObject, which is a base class derived from resource. The property is defined with the Embedded flag. This means that (like vectors defined using the Embedded flag) that you would expect to be able to create it’s content in place. @bas I vaguely remember we looked at this in the past…


#3

This isn’t supported at the moment in Napkin if I’m not mistaken, embedded objects can only be created if they are copy constructable in Napkin (defined using the RTTI_BEGIN_STRUCT macro) . A resource can’t be copy constructed and needs to be new’d.

So in JSON you can do this atm but from what I know Napkin doesn’t support this yet.


#4

I think there is a misunderstanding here, because as soon as the embedded (resource) objects are placed within a vector it works.


#5

Ah right, but that means it’s still not supported or covered correctly (this use case). That is a feature request / bug. But Napkin doesn’t corrupt the file on save right?


#6

Correct, nothing gets corrupted. I guess I can work around it by defining my resource in the root and make the property just point to it in a non-embedded way. I think it’s quite an important and powerful feature of the framework to be able to define resource objects polymorphically in json as members of other resources. And as I said, within a vector it already works in napkin too. :slight_smile:


#7

Agreed, will make a ticket.