Hello PlayCanvas team,
I think it would be great to have some sort of conditional attribute creation / update.
Here is the mockup code:
pc.script.attribute ('type', 'enumeration', 0,
{
displayName: 'Type',
enumerations:
[
{name: 'Default', value: 0},
{name: 'Jumppad', value: 1},
{name: 'Teleport', value: 2}
]
});
pc.script.onAttributeChange ('type', function (value)
{
if (value === 0)
{
// draw nothing
}
if (value === 1)
{
pc.script.attribute ('strength', 'number', 10);
}
if (value === 2)
{
pc.script.attribute ('radius', 'number', 5);
}
});
It would allow for using one generic script on multiple occasions without dealing with extending and polymorphism.
Thanks!