protected override void Init(string url, params object[] args) { base.Init(url, args); _assetFileBridge = AssetFileLoader.Load(url, (isOk, asset) => { if (IsReadyDisposed) // 中途释放 { OnFinish(null); return; } if (!isOk) { OnFinish(null); Log.Error("[InstanceAssetLoader]Error on assetfilebridge loaded... {0}", url); return; } try { InstanceAsset = (GameObject)GameObject.Instantiate(asset as UnityEngine.GameObject); } catch (Exception e) { throw new Core.AshException(e.Message); } if (Application.isEditor) { KResoourceLoadedAssetDebugger.Create("AssetCopy", url, InstanceAsset); } OnFinish(InstanceAsset); }); }
protected override void Init(string path, params object[] args) { var loaderMode = (LoaderMode)args[0]; base.Init(path, args); if (string.IsNullOrEmpty(path)) { Log.Error("StaticAssetLoader 空资源路径!"); } _assetFileLoader = AssetFileLoader.Load(path, (_isOk, _obj) => { OnFinish(_obj); if (Application.isEditor) { if (TheAsset != null) { KResoourceLoadedAssetDebugger.Create("StaticAsset", path, TheAsset); } } }); }
protected override void Init(string url, params object[] args) { var loaderMode = (LoaderMode)args[0]; base.Init(url, args); Object getAsset = null; string path = url; if (IsEditorLoadAsset) { #if UNITY_EDITOR if (path.EndsWith(".unity")) { // scene getAsset = KResourceLoader.Instance; Log.Warning("Load scene from Build Settings: {0}", path); } else { getAsset = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/" + path, typeof(UnityEngine.Object)); if (getAsset == null) { Log.Error("Asset is NULL(from {0} Folder): {1}", "ResourcesBuildDir", path); } } #else Log.Error("`IsEditorLoadAsset` is Unity Editor only"); #endif OnFinish(getAsset); } else { string extension = Path.GetExtension(path); path = path.Substring(0, path.Length - extension.Length); // remove extensions getAsset = Resources.Load <Object>(path); if (getAsset == null) { Log.Error("Asset is NULL(from Resources Folder): {0}", path); } OnFinish(getAsset); } if (Application.isEditor) { if (getAsset != null) { KResoourceLoadedAssetDebugger.Create(getAsset.GetType().Name, Url, getAsset as Object); } // 编辑器环境下,如果遇到GameObject,对Shader进行Fix if (getAsset is GameObject) { var go = getAsset as GameObject; foreach (var r in go.GetComponentsInChildren <Renderer>(true)) { RefreshMaterialsShaders(r); } } } if (getAsset != null) { // 更名~ 注明来源asset bundle 带有类型 getAsset.name = String.Format("{0}~{1}", getAsset, Url); } OnFinish(getAsset); }