Fix components undo issue in editor (#2871)

This commit is contained in:
pandamicro
2018-06-19 11:29:20 +08:00
committed by GitHub
parent 153b4f5867
commit 3e4171ef63
4 changed files with 29 additions and 0 deletions
+6
View File
@@ -172,6 +172,12 @@ let Graphics = cc.Class({
LineCap: LineCap
},
onRestore () {
if (!this._impl) {
this._impl = Graphics._assembler.createImpl();
}
},
onEnable () {
this._super();
this._activateMaterial();
+6
View File
@@ -322,6 +322,12 @@ let VideoPlayer = cc.Class({
}
},
onRestore () {
if (!this._impl) {
this._impl = new WebViewImpl();
}
},
onEnable () {
if (this._impl) {
this._impl.enable();
+6
View File
@@ -114,6 +114,12 @@ let WebView = cc.Class({
this._impl = new WebViewImpl();
},
onRestore () {
if (!this._impl) {
this._impl = new WebViewImpl();
}
},
onEnable () {
let impl = this._impl;
impl.createDomElementIfNeeded(this.node.width, this.node.height);
+11
View File
@@ -376,6 +376,17 @@ sp.Skeleton = cc.Class({
this._updateSkeletonData();
},
onRestore () {
// Destroyed and restored in Editor
if (!this._material) {
this._boundingBox = cc.rect();
this._material = new SpriteMaterial();
this._renderDatas = [];
this._debugNode = new Node();
this._debugRenderer = this._debugNode.addComponent(Graphics);
}
},
onDestroy () {
this._super();
this._debugNode.destroy();