Hello.
I am using cocos creator based on typescript.
Occasionally, the property values set in the scene disappear, so I figured out why.
As a result, if the class inheriting from cc.Component is inherited again, the added property will not work properly.
The steps are as follows.
- ‘SuperClass’ inherits from cc.Component, and ‘ChildClass’ inherits from ‘SuperClass’.
export default class SuperClass extends cc.Component { @property({ default: "hello" }) text: string = 'hello'; ... ... import SuperClass from "./SuperClass"; export default class ChildClass extends SuperClass { @property({ default: "" }) childText: string = '';
-
I use both ‘SuperClass’ and ‘ChildClass’ in the same scene, the ‘childText’ property of the ‘ChildClass’ will not work properly.
-
Changing the ‘childText’ value in the editor seems to work fine.
-
However, if i save the scene and load the scene again, the ‘childText’ value will remain empty.
I made a similar test with the javascript version, and it worked.
I do not understand why this is happening.