//-------∽-★-∽------∽-★-∽--------∽-★-∽资源加载∽-★-∽--------∽-★-∽------∽-★-∽--------// /// <summary> /// 同步加载 /// </summary> /// <param name="refer_"></param> /// <param name="url_"></param> /// <returns></returns> override public Object LoadSync(string url_, object refer_) { url_ = url_.ToLower(); AssetData data = CreateData(url_); data.Retain(refer_); if (data.asset) { return(data.asset); } Object asset = Resources.Load(data.url); if (asset == null) { Log.Assert("x 同步加载失败: " + data.url, this); return(null); } AddAsset(url_, asset); Log.Info("<color=yellow>同步加载: " + data.url + "</color>", this); return(asset); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽引用计数∽-★-∽--------∽-★-∽------∽-★-∽--------// /// <summary> /// 持有资源引用 /// </summary> /// <param name="url_"></param> /// <param name="refer_"></param> public void RetainByUrl(object refer_, string url_) { url_ = url_.ToLower(); AssetData data = CreateData(url_); data.Retain(refer_); data.active_time = DateUtil.TimeFromStart; //刷新时间 }
/// <summary> /// 异步加载 /// </summary> /// <param name="refer_"></param> /// <param name="url_"></param> /// <param name="onComplete_"></param> /// <returns></returns> override public AssetData LoadAsync(string url_, CALLBACK_1 onComplete_, object refer_) { url_ = url_.ToLower(); AssetData data = CreateData(url_); //先创建data, 用以记录生命周期等 data.Retain(refer_); if (data.asset != null) { //加载完成 if (onComplete_ != null) { onComplete_(data); } return(data); } if (m_url2req.ContainsKey(data.url)) { //加载中 if (onComplete_ != null) { Attach(data.url, onComplete_, refer_); } return(data); } //未启动加载, 至少保持一个引用 data.Retain(this); if (onComplete_ != null) { Attach(data.url, onComplete_, refer_); } CCApp.StartCoroutine(__LoadAsync(data.url)); return(data); }