Bug? - Inheriting attributes

I was playing around some more with script inheritance and encountered problems with attributes. I used the following script to test the following problems in an empty project.

1  var Test_Base = pc.createScript('test_Base');
3  Test_Base.attributes.add('dummy', { type: 'number', default: 10 });
5  Test_Base.prototype.initialize = function() { };
7  ////////////////////////////////   Child   ////////////////////////////////
9  var Test_Child = pc.createScript('test_Child');
11 // inheritance
12 Test_Child.prototype = Object.create(Test_Base.prototype);
13 Test_Child.prototype.constructor = Test_Child;
15 Test_Child.attributes.add('dummy', { type: 'number', default: 100 });
17 Test_Base.prototype.initialize = function() {
18     console.log(this.dummy);
19 };

Problem 1:
Attributes “seem” like they cannot be inherited, as they do not appear in the editor for child scripts. I need to define the same attribute for every child script (15), if I want them to expose the same attribute as their ancestor. Without it I can still access the dummy attribute with its default value. But as mentioned before the attribute is not exposed in the editor for Test_Child, so I can’t set the value outside of code.

Problem 2:
If I want to add attributes specific to the child script, their value is always undefined. If I comment out line 3 and break in line 18, I can see that the dummy attribute was added to the script, but it is undefined. So adding the attribute worked, but somehow somewhere, the value got lost/removed? I can only acces the dummy attribute’s value if I also add the attribute to the ancestor.
Contrary to Problem 1 though, the attribute still gets exposed in the editor, so it appears as if it could be set there.

Can someone help me out, explain to me what goes wrong here?
Thanks in advance


Script type inheritance isn’t right now supported by the editor/engine. I know that there was a hint by the Playcanvas team at some point for something like this but definitely isn’t there yet.

Not sure if you can trick the editor somehow to read your inherited object’s attributes correctly. If it is of any help here is the parse scripts worker to take a look on what it is looking for:


@will and @vaios may be able to comment on this.