cocos creator脚本与组件的关系
在组件中引入脚本,会发生了什么?
组件中引入的是脚本的uuid, 那么uuid怎么与代码对应起来
每个脚本的meta文件都有个uuid,在打包时uuid会被写入代码包里面, 解析代码包时,会把它解析出来并存起来

具体哪个类,负责存取的?
经过我的跟踪发现cc.Class(负责触发, js.js负责存储
//注册类(打一个断点,就知道了,角本包 window.__require()的时候,就注册了,这样组件就能用了
/**
* Register the class by specified name manually
* @method setClassName
* @param {String} className
* @param {Function} constructor
*/
js.setClassName = function (className, constructor) {
doSetClassName(className, constructor);
// auto set class id
if (!constructor.prototype.hasOwnProperty('__cid__')) {
var id = className || tempCIDGenerater.getNewId();
if (id) {
js._setClassId(id, constructor);
}
}
};
//读取类
/**
* Get the registered class by id
* @method _getClassById
* @param {String} classId
* @return {Function} constructor
* @private
*/
js._getClassById = function (classId) {
return _idToClass[classId];
};

浙公网安备 33010602011771号