mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
should not call onEnable if not executeInEditMode
This commit is contained in:
@@ -19,23 +19,23 @@ var callOnFocusInTryCatch = CC_EDITOR && eval(ExecInTryCatchTmpl.replace(/_FUNC_
|
||||
var callOnLostFocusInTryCatch = CC_EDITOR && eval(ExecInTryCatchTmpl.replace(/_FUNC_/g, 'onLostFocusInEditMode'));
|
||||
|
||||
function callOnEnable (self, enable) {
|
||||
//if (CC_EDITOR) {
|
||||
// if (enable ) {
|
||||
// if ( !(self._objFlags & IsEditorOnEnabledCalled) ) {
|
||||
// editorCallback.onComponentEnabled(self);
|
||||
// self._objFlags |= IsEditorOnEnabledCalled;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (self._objFlags & IsEditorOnEnabledCalled) {
|
||||
// editorCallback.onComponentDisabled(self);
|
||||
// self._objFlags &= ~IsEditorOnEnabledCalled;
|
||||
// }
|
||||
// }
|
||||
// if ( !(cc.game.isPlaying || self.constructor._executeInEditMode) ) {
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
if (CC_EDITOR) {
|
||||
//if (enable ) {
|
||||
// if ( !(self._objFlags & IsEditorOnEnabledCalled) ) {
|
||||
// editorCallback.onComponentEnabled(self);
|
||||
// self._objFlags |= IsEditorOnEnabledCalled;
|
||||
// }
|
||||
//}
|
||||
//else {
|
||||
// if (self._objFlags & IsEditorOnEnabledCalled) {
|
||||
// editorCallback.onComponentDisabled(self);
|
||||
// self._objFlags &= ~IsEditorOnEnabledCalled;
|
||||
// }
|
||||
//}
|
||||
if ( !(cc.engine.isPlaying || self.constructor._executeInEditMode) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var enableCalled = self._objFlags & IsOnEnableCalled;
|
||||
if (enable) {
|
||||
if (!enableCalled) {
|
||||
|
||||
@@ -19,6 +19,21 @@ test('Inheritance of editor properties', function () {
|
||||
strictEqual(child._playOnFocus, true, 'should inherit playOnFocus from base component');
|
||||
});
|
||||
|
||||
//test('should not call lifecycle methods if not executeInEditMode', function () {
|
||||
// var Comp = cc.Class({
|
||||
// extends: CallbackTester,
|
||||
// ctor: function () {
|
||||
// this.notExpect(CallbackTester.OnLoad, 'onLoad');
|
||||
// this.notExpect(CallbackTester.OnEnable, 'onEnable');
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// var parent = new cc.Node();
|
||||
// cc.director.getScene().addChild(parent);
|
||||
// var comp = parent.addComponent(Comp);
|
||||
// comp.stopTest();
|
||||
//});
|
||||
|
||||
//asyncTest('invoke using name', function () {
|
||||
// var cb = new Callback().setDisabledMessage('method should not invokes in this frame');
|
||||
// var cb2 = new Callback().disable('method should not being called after destroyed');
|
||||
|
||||
Reference in New Issue
Block a user