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

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

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 Likes

Right, the visible property. Of course. Thanks!

If we have more than one copy of same component in one node it calculates visibility wrong. Both components take values from latest component. A component should get values from itself not from neighbour component. Is there any fix?

[edit] This is fixed in Cocos Creator 1.9.3 Thx!