mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
45 lines
847 B
JavaScript
45 lines
847 B
JavaScript
function visitWrapper (wrapper, visitor) {
|
|
visitor(wrapper);
|
|
|
|
var children = wrapper._children;
|
|
for (var i = 0; i < children.length; i++) {
|
|
visitor(children[i]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Class for prefab handling.
|
|
* @class Prefab
|
|
* @extends Asset
|
|
* @constructor
|
|
*/
|
|
var Prefab = cc.Class({
|
|
name: 'cc.Prefab',
|
|
extends: cc.Asset,
|
|
|
|
properties: {
|
|
data: null
|
|
},
|
|
|
|
createNode: function (cb) {
|
|
if (CC_EDITOR) {
|
|
var node = cc.instantiate(this);
|
|
cb(null, node);
|
|
}
|
|
},
|
|
|
|
_instantiate: function () {
|
|
// instantiate
|
|
var node = cc.instantiate(this.data);
|
|
|
|
if (CC_DEV) {
|
|
Editor.PrefabUtils.linkPrefab(this, node);
|
|
}
|
|
|
|
return node;
|
|
}
|
|
});
|
|
|
|
cc.Prefab = module.exports = Prefab;
|
|
cc.js.obsolete(cc, 'cc._Prefab', 'Prefab');
|