mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-26 03:38: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: {
|
||||
default: true,
|
||||
tooltip: CC_DEV && 'i18n:COMPONENT.button.interactable',
|
||||
notify () {
|
||||
notify (oldValue) {
|
||||
if (oldValue !== this.interactable) {
|
||||
this._updateState();
|
||||
|
||||
if (!this.interactable) {
|
||||
this._resetState();
|
||||
}
|
||||
}
|
||||
},
|
||||
animatable: false
|
||||
},
|
||||
@ -581,7 +583,6 @@ let Button = cc.Class({
|
||||
},
|
||||
|
||||
update (dt) {
|
||||
let target = this._getTarget();
|
||||
if (this._transitionFinished) return;
|
||||
if (this.transition !== Transition.COLOR && this.transition !== Transition.SCALE) return;
|
||||
|
||||
@ -602,6 +603,7 @@ let Button = cc.Class({
|
||||
}
|
||||
// Skip if _originalScale is invalid
|
||||
else if (this.transition === Transition.SCALE && this._originalScale) {
|
||||
let target = this._getTarget();
|
||||
target.scale = this._fromScale.lerp(this._toScale, ratio);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user