public UnityEngine.Object GetAsset() { #if UNITY_EDITOR if (AssetBundleLoadManager.SimulateAssetBundleInEditor) { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(m_AssetBundleName, m_AssetName); if (assetPaths.Length == 0) { ATrace.LogError("There is no asset with name \"" + m_AssetName + "\" in " + m_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]); return(target); } #endif LoadedAssetBundle bundle = AssetBundleLoadManager.Instance.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError); if (bundle == null) { ATrace.Log("GetAsset fail:" + m_AssetBundleName); return(null); } if (m_Request != null && m_Request.isDone) { ATrace.Log("GetAsset succ:" + m_AssetBundleName); return(m_Request.asset); } else { return(null); } }
public override void DoCallback() { bool isdone = IsDone(); if (isdone) { if (m_LoadedCallback != null) { m_LoadedCallback(null, null); } } else { ATrace.LogError(string.Format("Asset: {0} - {1} Load Operation not done while do callback", m_AssetBundleName, m_AssetName)); } }
private IEnumerator Initialize() { #if UNITY_EDITOR // If we're in Editor simulation mode, we don't need the manifest assetBundle. if (SimulateAssetBundleInEditor) { yield break; } #endif string bundleName = AssetBundlePlatformPathManager.GetPlatformAssetbundlePath(); string assetName = "AssetBundleManifest"; WWW download = null; string url = ""; if (m_ManifestFromHttp == true) { url = AssetBundlePlatformPathManager.GetDownloadingHttpAssetBundleURL() + bundleName; } else { url = AssetBundlePlatformPathManager.GetAssetBundleDownloadingURL_StreamingAsset() + bundleName; } ATrace.Log("AssetBundle Manifest :" + url); download = new WWW(url); while (download.isDone != true) { yield return(0); } if (download.error != null) { ATrace.LogError(string.Format("AssetBundle Manifest load Error:{0}", download.error)); } else { m_AssetBundleManifest = download.assetBundle.LoadAsset <AssetBundleManifest>(assetName); if (m_AssetBundleManifest == null) { ATrace.LogError(string.Format("AssetBundle Manifest load Failed")); } else { } } }
void InitDic(XmlDocument xmldoc) { try { XmlNode node = xmldoc.ChildNodes.Item(0); int index = 0; foreach (XmlNode nodeChild in node.ChildNodes) { Dictionary <string, string> vals = new Dictionary <string, string>(); string mainkey = index.ToString(); bool valid = false; foreach (XmlAttribute valChild in nodeChild.Attributes) { string key = valChild.Name; string value = valChild.Value; vals[key] = value; if (!string.IsNullOrEmpty(value)) { valid = true; } } if (valid) { xmlTable.Add(mainkey, vals); } index++; } } catch (Exception e) { ATrace.LogError("Load Xml Failed : " + xmldoc.BaseURI); } }
public LoadedAssetBundle GetLoadedAssetBundle(string assetBundleName, out string error) { if (m_DownloadingErrors.TryGetValue(assetBundleName, out error)) { ATrace.LogError(string.Format("LoadedAssetBundel DownloadingErrors :{0}", error)); return(null); } LoadedAssetBundle bundle = null; m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle); if (bundle == null) { //ATrace.LogError(string.Format("LoadedAssetBundle :{0} not Found", assetBundleName)); return(null); } // No dependencies are recorded, only the bundle itself is required. string[] dependencies = null; if (!m_Dependencies.TryGetValue(assetBundleName, out dependencies)) { ATrace.Log("GetLoadedAssetBundle no dependency" + assetBundleName); return(bundle); } // Make sure all dependencies are loaded foreach (var dependency in dependencies) { // Wait all the dependent assetBundles being loaded. LoadedAssetBundle dependentBundle; m_LoadedAssetBundles.TryGetValue(dependency, out dependentBundle); if (dependentBundle == null) { //ATrace.LogError(string.Format("LoadedAssetBundel Dependency :{0} not Found", dependency)); return(null); } } ATrace.Log("GetLoadedAssetBundle with dependency" + assetBundleName); return(bundle); }
// Load AssetBundle and its dependencies. public void StartLoadAssetBundle(string assetBundleName, bool fromHttp) { if (!Working) { ATrace.LogError("AssetBundleLoadManager not Working"); StartCoroutine(WaitWorking(assetBundleName, fromHttp)); return; } if (m_DownloadingWWWs.ContainsKey(assetBundleName)) { ATrace.Log(string.Format("AssetBundleLoadManager already process AssetBundle:{0}", assetBundleName)); return; } if (m_LoadedAssetBundles.ContainsKey(assetBundleName)) { ATrace.Log(string.Format("AssetBundleLoadManager already loaded AssetBundle:{0}", assetBundleName)); return; } #if UNITY_EDITOR // If we're in Editor simulation mode, we don't have to really load the assetBundle and its dependencies. if (SimulateAssetBundleInEditor) { return; } #endif // Check if the assetBundle has already been processed. bool isAlreadyProcessed = LoadAssetBundleInternal(assetBundleName, fromHttp); // Load dependencies. if (!isAlreadyProcessed) { LoadDependencies(assetBundleName, fromHttp); } }