Cocos Creator doesn't recognize TypeScript properties with underscore "_"

With this simplest property you’ll get empty Component with no visible properties in Cocos Creator. Are there any solutions or that is intended behavior?

@ccclass
export class LetterView extends cc.Component {

    @property(cc.Sprite) private _icon: cc.Sprite;
}

It’s intended behavior, property with underscore are hidden.

You can override the behavior with explicitly visible attribute setting:

@property({
  type: cc.Sprite,
  default: null,
  visible: true
})
private _icon: cc.Sprite:
3 Likes

Have tried it and it works well.

Thanks a lot for a quick response and clarification!

Thanks! I was not aware of that attribute.

how to write this code in typeScript

smoothFollow: false,

     followX: {
                default: 0,
                visible () {
                     return this.smoothFollow;
                }
            },

it’s not work

 @property({
        default: false
    })
    smoothFollow=false;


    @property({
        default: false,
        visible () {
                return this.smoothFollow;
            }
    })

thanks.

From typescript documentation:

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/typescript/index.html

@property
_width = 100;

@property
get width () {
    return this._width;
}

@property
set width (value) {
    cc.log('width changed');
    return this._width = value;
}