我在写自定义按钮组件,但是我想duration 和zoomscale在面板上的显隐可以按照transition的类型来变化。 但是
this为undefined,请问官方有何办法不?
【cocos版本 2.0.5】
我在写自定义按钮组件,但是我想duration 和zoomscale在面板上的显隐可以按照transition的类型来变化。 但是
this为undefined,请问官方有何办法不?
【cocos版本 2.0.5】
我知道js的写法。但是 请问ts该如何实现
直接贴代码了:
const {ccclass, property} = cc._decorator;
@ccclass
export default class Helloworld extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
@property
_displayName = true;
@property({
displayName : "是否隐藏text属性",
})
set isDisplay(value: boolean) {
this._displayName = value;
cc.Class.Attr.setClassAttr(Helloworld, 'text', 'visible', value);
}
get isDisplay() {
return this._displayName;
}
start () {
// init logic
this.label.string = this.text;
}
}
非常感谢!!!
发现一个问题@BigBear, 这样改的话,会把所有的这个类的显隐属性都改掉
解决了
Vue.component(‘simple-button’, {
template: `
`,
props: {
target: {},
},
methods: {
valueIsEqual: (t, n) => t.value === n,
}
});
还有一种做法是在inspector里面直接写,用html的方式。类似写插件一样,有兴趣的话你可以去尝试一下
感觉现在creator里面想要继承系统组件,非常的麻烦
一般可能就是想加点属性,扩展一下功能
结果面板上就出来一大堆东西,还要去写inspector才行,真实麻烦的很啊
vue里的template不支持语法高亮,很不好维护,有什么解决方案吗
你这个方案能解决问题吗? 我用ts写的代码,一样使用的inspector插件来自定义组件的属性显示,但是不起作用。