static int _CreateAssetBundleParams(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3) { string arg0 = ToLua.CheckString(L, 1); System.Type arg1 = (System.Type)ToLua.CheckObject(L, 2, typeof(System.Type)); int arg2 = (int)LuaDLL.luaL_checknumber(L, 3); AssetBundleParams obj = new AssetBundleParams(arg0, arg1, arg2); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: AssetBundleParams.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//异步加载需常驻内存的资源 public Object LoadResidentMemoryObjAsync(AssetBundleParams abParams) { abParams.assetInMemoryType = AssetInMemoryType.Resident; //先返回null (TO DO) return(null); }
//场景资源预加载 public void PreloadSceneAsset(string sceneName, ref PreloadResult preloadResult) { this.preloadSceneResult = preloadResult; //获取预加载的场景数据(现在木有,先不处理) List <string> preLoadGOList = null; if (preLoadGOList != null && preLoadGOList.Count > 0) { this.preloadSceneResult.TotalCount += preLoadGOList.Count; } if (this.preloadSceneResult.TotalCount > 0) { //资源加载并生成相应预设 if (preLoadGOList != null) { IResourceMgr resMgr = GameKernel.Get <IResourceMgr>(); foreach (string item in preLoadGOList) { AssetBundleParams abp = new AssetBundleParams(item, typeof(GameObject)); resMgr.LoadNormalObjAsync(abp); } } } else { this.preloadSceneResult = null; } }
public bool LoadNormalObjAsync(AssetBundleParams abParams) { if (string.IsNullOrEmpty(abParams.path)) { return(false); } //先返回null (TO DO) return(false); }
static int LoadResidentMemoryObjAsync(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); XYHY.ResourceMgr obj = (XYHY.ResourceMgr)ToLua.CheckObject(L, 1, typeof(XYHY.ResourceMgr)); AssetBundleParams arg0 = (AssetBundleParams)ToLua.CheckObject(L, 2, typeof(AssetBundleParams)); UnityEngine.Object o = obj.LoadResidentMemoryObjAsync(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int LoadNormalObjAsync(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); XYHY.ResourceMgr obj = (XYHY.ResourceMgr)ToLua.CheckObject(L, 1, typeof(XYHY.ResourceMgr)); AssetBundleParams arg0 = (AssetBundleParams)ToLua.CheckObject(L, 2, typeof(AssetBundleParams)); bool o = obj.LoadNormalObjAsync(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 同步方式加载资源 /// </summary> /// <param name="path"></param> /// <returns></returns> public Object LoadNormalObjSync(AssetBundleParams abParams) { Object retObj = null; #if UNITY_EDITOR && false retObj = LoadInEditor(abParams.path, abParams.type); #else retObj = LoadFromResource(abParams.path); #endif if (retObj == null) { Debugger.LogWarning(string.Format("该资源不存在,路径:{0},类型:{1}", abParams.path, abParams.type)); } return(retObj); }
static int get_type(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; System.Type ret = obj.type; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index type on a nil value" : e.Message)); } }
static int get_IsPreloadMainAsset(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; bool ret = obj.IsPreloadMainAsset; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsPreloadMainAsset on a nil value" : e.Message)); } }
static int set_callbackActQueue(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; System.Collections.Generic.Queue <System.Action <UnityEngine.GameObject, UnityEngine.GameObject> > arg0 = (System.Collections.Generic.Queue <System.Action <UnityEngine.GameObject, UnityEngine.GameObject> >)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.Queue <System.Action <UnityEngine.GameObject, UnityEngine.GameObject> >)); obj.callbackActQueue = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index callbackActQueue on a nil value" : e.Message)); } }
static int set_IsPreloadMainAsset(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.IsPreloadMainAsset = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsPreloadMainAsset on a nil value" : e.Message)); } }
static int set_assetInMemoryType(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; AssetInMemoryType arg0 = (AssetInMemoryType)ToLua.CheckObject(L, 2, typeof(AssetInMemoryType)); obj.assetInMemoryType = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index assetInMemoryType on a nil value" : e.Message)); } }
static int set_uid(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.uid = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index uid on a nil value" : e.Message)); } }
static int set_path(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; string arg0 = ToLua.CheckString(L, 2); obj.path = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index path on a nil value" : e.Message)); } }
static int get_callbackActQueue(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; System.Collections.Generic.Queue <System.Action <UnityEngine.GameObject, UnityEngine.GameObject> > ret = obj.callbackActQueue; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index callbackActQueue on a nil value" : e.Message)); } }
static int get_path(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; string ret = obj.path; LuaDLL.lua_pushstring(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index path on a nil value" : e.Message)); } }
static int get_uid(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); AssetBundleParams obj = (AssetBundleParams)o; int ret = obj.uid; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index uid on a nil value" : e.Message)); } }
void initAsset() { preloadResult = null; preloadResult = new PreloadResult(); GameKernel.CreateForInitData(); IResourceMgr resourceMgr = GameKernel.Get <IResourceMgr>(); ResBinData iResBinData = NewResBinDataForPreLoad(); //预加载资源,不需要提前获取mainAsset List <string> residentGoList = iResBinData.GetImmortalAssetList(1); List <string> residentACList = iResBinData.GetImmortalAssetList(3); List <string> residentTexture2DList = iResBinData.GetImmortalAssetList(5); List <string> residentAudioClipList = iResBinData.GetImmortalAssetList(7); List <string> residentAnimClipList = iResBinData.GetImmortalAssetList(9); //预加载资源,需要提前获取mainAsset List <string> residentPreloadGoList = iResBinData.GetImmortalAssetList(2); List <string> residentPreloadACList = iResBinData.GetImmortalAssetList(4); List <string> residentPreloadTexture2DList = iResBinData.GetImmortalAssetList(6); List <string> residentPreloadAudioClipList = iResBinData.GetImmortalAssetList(8); List <string> residentPreloadAnimClipList = iResBinData.GetImmortalAssetList(10); if (residentGoList != null && residentGoList.Count > 0) { this.preloadResult.TotalCount += residentGoList.Count; } if (residentPreloadGoList != null && residentPreloadGoList.Count > 0) { this.preloadResult.TotalCount += residentPreloadGoList.Count; } if (residentACList != null && residentACList.Count > 0) { this.preloadResult.TotalCount += residentACList.Count; } if (residentPreloadACList != null && residentPreloadACList.Count > 0) { this.preloadResult.TotalCount += residentPreloadACList.Count; } if (residentTexture2DList != null && residentTexture2DList.Count > 0) { this.preloadResult.TotalCount += residentTexture2DList.Count; } if (residentPreloadTexture2DList != null && residentPreloadTexture2DList.Count > 0) { this.preloadResult.TotalCount += residentPreloadTexture2DList.Count; } if (residentAudioClipList != null && residentAudioClipList.Count > 0) { this.preloadResult.TotalCount += residentAudioClipList.Count; } if (residentPreloadAudioClipList != null && residentPreloadAudioClipList.Count > 0) { this.preloadResult.TotalCount += residentPreloadAudioClipList.Count; } if (residentAnimClipList != null && residentAnimClipList.Count > 0) { this.preloadResult.TotalCount += residentAnimClipList.Count; } if (residentPreloadAnimClipList != null && residentPreloadAnimClipList.Count > 0) { this.preloadResult.TotalCount += residentPreloadAnimClipList.Count; } if (residentGoList != null) { for (int i = 0; i < residentGoList.Count; i++) { abp = new AssetBundleParams(residentGoList[i], typeof(GameObject)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadGoList != null) { for (int i = 0; i < residentPreloadGoList.Count; i++) { abp = new AssetBundleParams(residentPreloadGoList[i], typeof(GameObject)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentACList != null) { for (int i = 0; i < residentACList.Count; i++) { abp = new AssetBundleParams(residentACList[i], typeof(RuntimeAnimatorController)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadACList != null) { for (int i = 0; i < residentPreloadACList.Count; i++) { abp = new AssetBundleParams(residentPreloadACList[i], typeof(RuntimeAnimatorController)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentTexture2DList != null) { for (int i = 0; i < residentTexture2DList.Count; i++) { abp = new AssetBundleParams(residentTexture2DList[i], typeof(Texture2D)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadTexture2DList != null) { for (int i = 0; i < residentPreloadTexture2DList.Count; i++) { abp = new AssetBundleParams(residentPreloadTexture2DList[i], typeof(Texture2D)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentAudioClipList != null) { for (int i = 0; i < residentAudioClipList.Count; i++) { abp = new AssetBundleParams(residentAudioClipList[i], typeof(AudioClip)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadAudioClipList != null) { for (int i = 0; i < residentPreloadAudioClipList.Count; i++) { abp = new AssetBundleParams(residentPreloadAudioClipList[i], typeof(AudioClip)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentAnimClipList != null) { for (int i = 0; i < residentAnimClipList.Count; i++) { abp = new AssetBundleParams(residentAnimClipList[i], typeof(AnimationClip)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadAnimClipList != null) { for (int i = 0; i < residentPreloadAnimClipList.Count; i++) { abp = new AssetBundleParams(residentPreloadAnimClipList[i], typeof(AnimationClip)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } ReleaseNewResBinData(); }