// Load asset from the given assetBundle. public AssetBundleLoadAssetOperation ABM_10_LoadAssetAsync (string assetBundleName, string assetName, System.Type type) { Debug.Log ("------------ABM_10_LoadAssetAsync----------------------assetBundleName ="+assetBundleName+" assetName= "+assetName +" type="+type); AssetBundleLoadAssetOperation operation = null; /* #if UNITY_EDITOR if (ABM_00_SimulateAssetBundleInEditor) { Debug.Log ("------------ABM_10_LoadAssetAsync----------■------------ABM_00_SimulateAssetBundleInEditor ="+ABM_00_SimulateAssetBundleInEditor+" assetBundleName="+assetBundleName+" assetName= "+assetName +" type="+type); string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); if (assetPaths.Length == 0) { Debug.Log ("------------ABM_10_LoadAssetAsync--------■-------------ABM_00_SimulateAssetBundleInEditor ="+ABM_00_SimulateAssetBundleInEditor+" assetBundleName="+assetBundleName+" assetName= "+assetName +" assetPaths.Length="+assetPaths.Length); Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); return null; } // @TODO: Now we only get the main object from the first asset. Should consider type also. Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); operation = new AssetBundleLoadAssetOperationSimulation (target); Debug.Log ("------------ABM_10_LoadAssetAsync---------■------------ABM_00_SimulateAssetBundleInEditor ="+ABM_00_SimulateAssetBundleInEditor+" assetBundleName="+assetBundleName+" assetName= "+assetName +" target"+target+" operation"+operation); } else #endif */ { Debug.Log ("------------ABM_10_LoadAssetAsync-----------else----------- assetBundleName="+assetBundleName+" assetName= "+assetName ); ABM_03_LoadAssetBundle (assetBundleName); operation = new AssetBundleLoadAssetOperationFull (assetBundleName, assetName, type); m_InProgressOperations.Add (operation); } Debug.Log ("------------ABM_10_LoadAssetAsync------------------ assetBundleName="+assetBundleName+" assetName= "+assetName +" operation="+operation); return operation; }
// Load asset from the given assetBundle. static public AssetBundleLoadAssetOperation LoadAssetAsync (string assetBundleName, string assetName, System.Type type) { AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); if (assetPaths.Length == 0) { Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); return null; } // @TODO: Now we only get the main object from the first asset. Should consider type also. Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); operation = new AssetBundleLoadAssetOperationSimulation (target); } else #endif { LoadAssetBundle (assetBundleName); operation = new AssetBundleLoadAssetOperationFull (assetBundleName, assetName, type); m_InProgressOperations.Add (operation); } return operation; }
public static AssetBundleLoadAssetOperation LoadAssetAsync(string assetBundleName, string assetName, System.Type type) { AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); if (assetPaths.Length == 0) { Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); return(null); } UnityEngine.Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); operation = new AssetBundleLoadAssetOperationSimulation(target); } else #endif { assetBundleName = RemapVariantName(assetBundleName); LoadAssetBundleAsync(assetBundleName, true, true); operation = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type); m_InProgressOperations.Add(operation); } return(operation); }
static public int GetGameObject(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif AssetBundleLoadAssetOperationFull self = (AssetBundleLoadAssetOperationFull)checkSelf(l); var ret = self.GetGameObject(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
// Load asset from the given assetBundle. static public AssetBundleLoadAssetOperation LoadAssetAsync (string assetBundleName, string assetName, System.Type type) { AssetBundleLoadAssetOperation operation = null; //unity_editor comment by weihua.cui //#if UNITY_EDITOR // if (SimulateAssetBundleInEditor) // { // string[] tempPaths = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName); // string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); // Debug.Log(assetPaths); // if (assetPaths.Length == 0) // { // Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); // return null; // } // // @TODO: Now we only get the main object from the first asset. Should consider type also. // Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); // operation = new AssetBundleLoadAssetOperationSimulation(target); // } // else //#endif { LoadAssetBundle (assetBundleName); operation = new AssetBundleLoadAssetOperationFull (assetBundleName, assetName, type); m_InProgressOperations.Add (operation); } return operation; }
public static AssetBundleLoadAssetOperation LoadAssetAsync(string assetBundleName, string assetName, System.Type type, int dlcType) { LoadAssetBundle(assetBundleName, dlcType); AssetBundleLoadAssetOperation operation = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type); inProgressOperationList.Add(operation); return(operation); }
// Load asset from the given assetBundle. public AssetBundleLoadAssetOperation LoadAssetAsync(string a_assetBundleName, string a_assetName, Type a_type) { if (string.IsNullOrEmpty(a_assetBundleName) || string.IsNullOrEmpty(a_assetName)) { return(null); } AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { string[] paths = null; if (!s_cachedPathsForBundle.TryGetValue(a_assetBundleName, out paths)) { paths = AssetDatabase.GetAssetPathsFromAssetBundle(a_assetBundleName); s_cachedPathsForBundle.Add(a_assetBundleName, paths); } //var assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(a_assetBundleName, a_assetName); if (!paths.Contains(a_assetName)) { Debug.LogError("There is no asset with name \"" + a_assetName + "\" in " + a_assetBundleName); return(null); } var target = AssetDatabase.LoadAssetAtPath(a_assetName, a_type); operation = new AssetBundleLoadAssetOperationSimulation(target); } else #endif { var key = AssetToKey(a_assetBundleName, a_assetName); AssetBundleLoadOperation inProgressOperation; if (m_inProgressOperationsByName.TryGetValue(key, out inProgressOperation)) { if (inProgressOperation is AssetBundleLoadAssetOperation) { return(inProgressOperation as AssetBundleLoadAssetOperation); } } LoadAssetBundle(a_assetBundleName); operation = new AssetBundleLoadAssetOperationFull(a_assetBundleName, a_assetName, a_type); //Debug.Log("Adding operation " + a_assetName); m_inProgressOperationsByName.Add(key, operation); m_inProgressOperations.Add(new KeyValuePair <string, AssetBundleLoadOperation>(key, operation)); } return(operation); }
// Load asset from the given assetBundle. public AssetBundleLoadAssetOperation LoadAssetAsync (string assetBundleName, string assetName, System.Type type) { AssetBundleLoadAssetOperation operation = null; LoadAssetBundle (assetBundleName); operation = new AssetBundleLoadAssetOperationFull (assetBundleName, assetName, type); m_InProgressOperations.Add (operation); return operation; }
// Load asset from the given assetBundle. static public AssetBundleLoadAssetOperation LoadAssetAsync (string assetBundleName, string assetName, System.Type type) { AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor == LoadMode.AssetBundleName) { //GetAssetPathsFromAssetBundleAndAssetName接口对大小写敏感 assetBundleName = assetBundleName.ToLower(); assetName = assetName.ToLower(); Debug.LogError("AssetBudle" + AssetDatabase.GetAllAssetBundleNames()); string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); if (assetPaths.Length == 0) { Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); return null; } // @TODO: Now we only get the main object from the first asset. Should consider type also. Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); operation = new AssetBundleLoadAssetOperationSimulation (target); } else if (SimulateAssetBundleInEditor == LoadMode.LoadAssetAtPath) { Object target = null; for (int i = 0; i < extension.Length; i++) { //去掉后缀 string bundleName = assetBundleName.Replace(System.IO.Path.GetExtension(assetBundleName), extension[i]); //直接预制体加载 target = AssetDatabase.LoadAssetAtPath<Object>(bundleName); if (target != null) break; } operation = new AssetBundleLoadAssetOperationSimulation(target); } else #endif { LoadAssetBundle (assetBundleName); operation = new AssetBundleLoadAssetOperationFull (assetBundleName, assetName, type); m_InProgressOperations.Add (operation); } return operation; }
IEnumerator LoadAssetAsync <T>(string assetBundleName, string assetName, System.Action <T, bool> callback) where T : UnityEngine.Object { LoadAssetBundle(assetBundleName, GetLevel(assetBundleName, assetName)); AssetBundleLoadAssetOperation request = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, typeof(T)); m_InProgressOperations.Add(request); yield return(StartCoroutine(request)); T obj = (T)request.GetAsset <UnityEngine.Object>(); InitHideFlag(obj); if (callback == null || callback.Target == null || "null".Equals(callback.Target.ToString())) { yield break; } callback.Invoke(obj, IsValid(obj)); callback = null; }
// Load asset from the given assetBundle. static public AssetBundleLoadAssetOperation LoadAssetAsync(string assetBundleName, string assetName, System.Type type, bool bSingle = true) { AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { SampleDebuger.Log("LoadAssetAsync " + assetBundleName); operation = new AssetBundleLoadAssetOperationSimulation(assetBundleName, assetName, bSingle); } else #endif { LoadAssetBundle(assetBundleName); operation = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type, bSingle); m_InProgressOperations.Add(operation); } return operation; }
static public int constructor(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif AssetBundleLoadAssetOperationFull o; System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Type a3; checkType(l, 4, out a3); o = new AssetBundleLoadAssetOperationFull(a1, a2, a3); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
protected IEnumerator LoadSpriteAsync(string assetBundleName, string spritename, System.Action <Sprite> OnLoad, System.Action OnPackError) { // This is simply to get the elapsed time for this phase of AssetLoading. float startTime = Time.realtimeSinceStartup; // Load asset from assetBundle. AssetBundleLoadAssetOperationFull request = AssetManager.LoadAssetAsync(assetBundleName, spritename, typeof(Sprite), true); if (request == null) { yield break; } yield return(StartCoroutine(request)); // Get the asset. Sprite s = request.GetAsset <Sprite>(spritename); if (s != null) { if (null != OnLoad) { OnLoad(s); } } else { if (null != OnPackError) { OnPackError(); } } // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log(spritename + (s == null ? " was not" : " was") + " loaded successfully in " + elapsedTime + " seconds"); }
// Starts a load operation for an asset from the given asset bundle. static public AssetBundleLoadAssetOperation LoadAssetAsync(string assetBundleName, string assetName, System.Type type) { Log(LogType.Info, "Loading " + assetName + " from " + assetBundleName + " bundle"); AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); if (assetPaths.Length == 0) { Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); return null; } // @TODO: Now we only get the main object from the first asset. Should consider type also. UnityEngine.Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); operation = new AssetBundleLoadAssetOperationSimulation(target); } else #endif { assetBundleName = RemapVariantName(assetBundleName); LoadAssetBundle(assetBundleName); operation = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type); m_InProgressOperations.Add(operation); } return operation; }
// Load asset from the given assetBundle. public static AssetBundleLoadAssetOperation LoadAssetAsync(string assetBundleName, string assetName, System.Type type) { AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); foreach (var path in assetPaths) { Debuger.Log("LoadAssetAsync " + path); } // if (assetPaths.Length == 0) // { // Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); // return null; // } // @TODO: Now we only get the main object from the first asset. Should consider type also. Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); operation = new AssetBundleLoadAssetOperationSimulation (target); } else #endif { LoadAssetBundle (assetBundleName); operation = new AssetBundleLoadAssetOperationFull (assetBundleName, assetName, type); m_InProgressOperations.Add (operation); } return operation; }