mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-26 11:48:29 +00:00
[engine] 优化 cc.Button 性能,interactable 未改变时不进行材质切换,减少 update 时需执行的逻辑
This commit is contained in:
parent
f853ea7da3
commit
a14c457602
@ -184,12 +184,14 @@ let Button = cc.Class({
|
|||||||
interactable: {
|
interactable: {
|
||||||
default: true,
|
default: true,
|
||||||
tooltip: CC_DEV && 'i18n:COMPONENT.button.interactable',
|
tooltip: CC_DEV && 'i18n:COMPONENT.button.interactable',
|
||||||
notify () {
|
notify (oldValue) {
|
||||||
|
if (oldValue !== this.interactable) {
|
||||||
this._updateState();
|
this._updateState();
|
||||||
|
|
||||||
if (!this.interactable) {
|
if (!this.interactable) {
|
||||||
this._resetState();
|
this._resetState();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
animatable: false
|
animatable: false
|
||||||
},
|
},
|
||||||
@ -581,7 +583,6 @@ let Button = cc.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
update (dt) {
|
update (dt) {
|
||||||
let target = this._getTarget();
|
|
||||||
if (this._transitionFinished) return;
|
if (this._transitionFinished) return;
|
||||||
if (this.transition !== Transition.COLOR && this.transition !== Transition.SCALE) return;
|
if (this.transition !== Transition.COLOR && this.transition !== Transition.SCALE) return;
|
||||||
|
|
||||||
@ -602,6 +603,7 @@ let Button = cc.Class({
|
|||||||
}
|
}
|
||||||
// Skip if _originalScale is invalid
|
// Skip if _originalScale is invalid
|
||||||
else if (this.transition === Transition.SCALE && this._originalScale) {
|
else if (this.transition === Transition.SCALE && this._originalScale) {
|
||||||
|
let target = this._getTarget();
|
||||||
target.scale = this._fromScale.lerp(this._toScale, ratio);
|
target.scale = this._fromScale.lerp(this._toScale, ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user