mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Merge pull request #710 from jareguo/master
make sizeProvider error more clear
This commit is contained in:
@@ -149,8 +149,15 @@ var Canvas = cc.Class({
|
||||
if ( !this.node._sizeProvider ) {
|
||||
this.node._sizeProvider = designResolutionWrapper;
|
||||
}
|
||||
else {
|
||||
cc.error('CCCanvas: Node can only have one size.');
|
||||
else if (CC_DEV) {
|
||||
var renderer = this.node.getComponent(cc._RendererUnderSG);
|
||||
if (renderer) {
|
||||
cc.error('Should not add Canvas to a node which already contains a renderer component (%s).',
|
||||
cc.js.getClassName(renderer));
|
||||
}
|
||||
else {
|
||||
cc.error('Should not add Canvas to a node which size is already used by its other component.');
|
||||
}
|
||||
}
|
||||
|
||||
cc.director.on(cc.Director.EVENT_BEFORE_VISIT, this.alignWithScreen, this);
|
||||
|
||||
@@ -400,9 +400,7 @@ var Label = cc.Class({
|
||||
if (this.overflow === Overflow.NONE) {
|
||||
this.node.setContentSize(this._sgNode.getContentSize());
|
||||
}
|
||||
if ( !this.node._sizeProvider ) {
|
||||
this.node._sizeProvider = this._sgNode;
|
||||
}
|
||||
this._registSizeProvider();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,10 +57,7 @@ var RendererUnderSG = cc.Class({
|
||||
// and remember to hide the sgNode if component.enabledInHierarchy is false.
|
||||
__preload: function () {
|
||||
this._initSgNode();
|
||||
var sgNode = this._sgNode;
|
||||
if ( !this.node._sizeProvider ) {
|
||||
this.node._sizeProvider = sgNode;
|
||||
}
|
||||
this._registSizeProvider();
|
||||
this._appendSgNode(this._sgNode);
|
||||
},
|
||||
|
||||
|
||||
@@ -79,6 +79,21 @@ var SGComponent = cc.Class({
|
||||
* @private
|
||||
*/
|
||||
_removeSgNode: SceneGraphHelper.removeSgNode,
|
||||
|
||||
_registSizeProvider: function () {
|
||||
if ( !this.node._sizeProvider ) {
|
||||
this.node._sizeProvider = this._sgNode;
|
||||
}
|
||||
else if (CC_DEV) {
|
||||
var name = cc.js.getClassName(this);
|
||||
if (this.node.getComponent(cc.Canvas)) {
|
||||
cc.error('Should not add renderer component (%s) to a Canvas node.', name);
|
||||
}
|
||||
else {
|
||||
cc.error('Should not add %s to a node which size is already used by its other component.', name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cc._SGComponent = module.exports = SGComponent;
|
||||
|
||||
@@ -61,9 +61,7 @@ var TiledLayer = cc.Class({
|
||||
if ( !this.enabledInHierarchy ) {
|
||||
sgNode.setVisible(false);
|
||||
}
|
||||
if ( !this.node._sizeProvider ) {
|
||||
this.node._sizeProvider = sgNode;
|
||||
}
|
||||
this._registSizeProvider();
|
||||
var node = this.node;
|
||||
sgNode.setAnchorPoint(node.getAnchorPoint());
|
||||
},
|
||||
|
||||
@@ -815,9 +815,7 @@ sp.Skeleton = cc.Class({
|
||||
sgNode.setContentSize(0, 0); // restore content size
|
||||
self._initSgNode();
|
||||
self._appendSgNode(sgNode);
|
||||
if ( !self.node._sizeProvider ) {
|
||||
self.node._sizeProvider = sgNode;
|
||||
}
|
||||
self._registSizeProvider();
|
||||
}
|
||||
|
||||
if (CC_EDITOR) {
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@
|
||||
"require-dir": "0.3.0",
|
||||
"vinyl": "1.1.0",
|
||||
"vinyl-buffer": "1.0.0",
|
||||
"vinyl-source-stream": "1.0.0"
|
||||
"vinyl-source-stream": "1.0.0",
|
||||
"watchify": "^3.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user