In editor, how to show/hide property in component according to value set in another property?

In editor, how to show/hide property in component according to value set in another property?
0.0 0

#1

For example, in the Sprite component, if you set the Type property to FILLED, properties related to filled type sprites (Fill Type, Fill Center, Fill Start, Fill Range) are shown. When Type is set to any other type, the properties are hidden. How can I create this effect in my custom components? I’d like to make components less cluttered for the designer.

cocos-forum


#2

hi ,
you can do something like this.

cc.Class({
    extends: cc.Component,

    properties: {

        showNextProp : {
            default : true,

        },
        textLabel : {
            default: " Label ",
            visible : function () {
                return this.showNextProp;
            }
        }

    },

    onLoad () {},

});

you can get the idea about other kind of situations.


#3

Right, the visible property. Of course. Thanks!