//异步加载 public void LoadAsync(IXAssetManager manager, EnumFileLocation location, EnumBundleType bundleType, string name, Action <string, AssetBundle> callback = null) { m_AssetManager = manager; m_BundleName = name; m_dependencies.Clear(); var dependencies = manager.GetDependencies(m_BundleName); if (dependencies != null) { m_dependencies.AddRange(dependencies); m_dependencyCurCount = 0; m_dependencyMaxCount = dependencies.Count; foreach (var dependent in dependencies) { manager.LoadBundleAsync(dependent, _OnLoadedDependent); } } var fullPath = XABUtilities.GetBundleFullPath(location, bundleType, name); XDebug.Log(XABConst.Tag, $"加载 {fullPath}"); _StartLoadAsync(fullPath); m_state = EnumJobState.Process; m_callback += callback; }
void _CollectManifestData(XABManifest manifest, EnumBundleType bundleType) { if (manifest == null) { return; } var datas = manifest.GetAssetNameToBundleNameDatas(); foreach (var pairs in datas) { if (m_dictAssetNameToBundleName.ContainsKey(pairs.Key)) { Debug.LogError($"资源名重复 {pairs.Key}"); continue; } m_dictAssetNameToBundleName.Add(pairs.Key, pairs.Value); } var dependencyDatas = manifest.GetDependencyDatas(); foreach (var pairs in dependencyDatas) { if (m_dictBundles.ContainsKey(pairs.Key)) { Debug.LogError($"包名重复 {pairs.Key}"); continue; } var bundleInfo = new BundleInfo(); bundleInfo.dependencies = pairs.Value.values; bundleInfo.bundleType = bundleType; m_dictBundles.Add(pairs.Key, bundleInfo); } }
//获取资源路径 public static string GetResPath(EnumFileLocation location, EnumBundleType bundleType) { #if UNITY_EDITOR var mode = (EnumResMode)EditorPrefs.GetInt(XABConst.EKResMode, XABConst.EKResModeValue); //模拟模式 if (mode == EnumResMode.Simulate) { return(string.Empty); } //本地模式 if (mode == EnumResMode.Local) { return($"{GetResPathEditSet()}/{bundleType.ToString()}"); } //远程模式 if (mode == EnumResMode.Remote) { var path = string.Empty; switch (bundleType) { case EnumBundleType.Static: path = GetResPathEditSet(); break; case EnumBundleType.Hotfix: path = XABConst.DocumentPath; break; } return($"{path}/{bundleType.ToString()}");; } #endif //发布模式 if (location == EnumFileLocation.Client) { return($"{XABConst.DocumentPath}/{bundleType.ToString()}"); } if (location == EnumFileLocation.Stream) { #if UNITY_EDITOR return($"{GetResPathEditSet()}/{bundleType.ToString()}"); #endif return($"{XABConst.StreamingAssetsPath}/{bundleType.ToString()}"); } return(string.Empty); }
//同步加载 public void Load(IXAssetManager manager, EnumFileLocation location, EnumBundleType bundleType, string name) { m_AssetManager = manager; m_BundleName = name; m_dependencies.Clear(); var dependencies = manager.GetDependencies(m_BundleName); if (dependencies != null) { m_dependencies.AddRange(dependencies); foreach (var dependency in dependencies) { manager.LoadBundle(dependency); } } var fullPath = XABUtilities.GetBundleFullPath(location, bundleType, name); XDebug.Log(XABConst.Tag, $"加载 {fullPath}"); SetValue(_LoadInternal(fullPath)); }
//获取资源包完整路径 public static string GetBundleFullPath(EnumFileLocation location, EnumBundleType bundleType, string bundleName) { return($"{GetResPath(location, bundleType)}/{bundleName}"); }
static JDFAutoBundle() { atrInfoTable[0] = new AtrInfoTable(AttributeName.BUNDLETYPE, 0x33333331, AttributeInfo.EnumAttributeType.enumeration, EnumBundleType.getEnum(0), "Stack"); atrInfoTable[1] = new AtrInfoTable(AttributeName.FOLIOCOUNT, 0x33333331, AttributeInfo.EnumAttributeType.integer, null, null); atrInfoTable[2] = new AtrInfoTable(AttributeName.READERPAGECOUNT, 0x33333331, AttributeInfo.EnumAttributeType.integer, null, null); atrInfoTable[3] = new AtrInfoTable(AttributeName.TOTALAMOUNT, 0x33333331, AttributeInfo.EnumAttributeType.integer, null, null); elemInfoTable[0] = new ElemInfoTable(ElementName.BUNDLEITEM, 0x33333331); elemInfoTable[1] = new ElemInfoTable(ElementName.CONTACT, 0x33333331); elemInfoTable[2] = new ElemInfoTable(ElementName.IDENTIFICATIONFIELD, 0x33333331); }
/// /// <summary> * (9) get attribute BundleType </summary> /// * <returns> the value of the attribute </returns> /// public virtual EnumBundleType getBundleType() { return(EnumBundleType.getEnum(getAttribute(AttributeName.BUNDLETYPE, null, "Stack"))); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute BundleType // --------------------------------------------------------------------- /// /// <summary> * (5) set attribute BundleType </summary> /// * <param name="enumVar">: the enumVar to set the attribute to </param> /// public virtual void setBundleType(EnumBundleType enumVar) { setAttribute(AttributeName.BUNDLETYPE, enumVar == null ? null : enumVar.getName(), null); }