Example #1
0
    static void CreateAllBundleData(Object[] assetObjects)
    {
        //用于去除重复的List
        List <string> assetNameList = new List <string>();

        foreach (var assetObject in assetObjects)
        {
            string dataName = AssetDatabase.GetAssetPath(assetObject);

            if (assetNameList.Contains(dataName))
            {
                continue;
            }
            else
            {
                assetNameList.Add(dataName);
            }

            BundleData newBundleData = new BundleData();
            newBundleData.name = assetObject.name;
            newBundleData.includs.Add(dataName);

            //get denpendency
            string[] files            = BuildHelper.GetAssetsFromPaths(newBundleData.includs.ToArray(), newBundleData.sceneBundle);
            string[] dependAssetNames = AssetDatabase.GetDependencies(files);

            newBundleData.dependAssets = new List <string>(dependAssetNames);

            _orignalBundleDatas.Add(newBundleData);
        }
    }
Example #2
0
    /**
     * Test if path can be added to bundle.
     * @param path The path must be a path under Asset. Can be path of diretory or file.
     * @param bundleName The bundle's name.
     */
    public static bool CanAddPathToBundle(string path, string bundleName)
    {
        BundleData bundle = GetBundleData(bundleName);

        if (bundle == null || Path.IsPathRooted(path) || (!File.Exists(path) && !Directory.Exists(path)))
        {
            return(false);
        }

        if (bundle.includs.Contains(path))
        {
            return(false);
        }

        if (ContainsFileInPath(path, sceneDetector) && !bundle.sceneBundle)
        {
            return(false);
        }
        else if (ContainsFileInPath(path, assetDetector) && bundle.sceneBundle)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Example #3
0
    internal static void AddBundleToBuildList(string bundleName, ref Dictionary <string, List <string> > buildingRoutes)
    {
        BundleData bundle = BundleManager.GetBundleData(bundleName);
        var        state  = BundleManager.GetBuildStateOfBundle(bundleName);

        if (bundle == null)
        {
            Debug.LogError("Cannot find bundle " + bundleName);
            return;
        }

        //if( BuildHelper.IsBundleNeedBunild(bundle) )
        if (state.changed)
        {
            string rootName = BundleManager.GetRootOf(bundle.name);
            if (buildingRoutes.ContainsKey(rootName))
            {
                if (!buildingRoutes[rootName].Contains(bundle.name))
                {
                    buildingRoutes[rootName].Add(bundle.name);
                }
                else
                {
                    Debug.LogError("Bundle name duplicated: " + bundle.name);
                }
            }
            else
            {
                List <string> buildingList = new List <string>();
                buildingList.Add(bundle.name);
                buildingRoutes.Add(rootName, buildingList);
            }
        }
    }
Example #4
0
    static int CreateTopCommonBundle()
    {
        //找到最大依赖,创建顶层common包
        var maxNum = _dependAssetNum.Values.Max();

        if (maxNum == 1)
        {
            // 所有的AssetBundle没有公共依赖,加入一个占位文件
            commonBundleData      = new BundleData();
            commonBundleData.name = _currentCategre + "Common";

            commonBundleData.includs.Add("Assets/CommonEmpty.txt");
        }
        else
        {
            var maxAsset = _dependAssetNum.Where(pair => maxNum.Equals(pair.Value)).Select(pair => pair.Key);

            commonBundleData      = new BundleData();
            commonBundleData.name = _currentCategre + "Common";
            foreach (var asset in maxAsset)
            {
                commonBundleData.includs.Add(asset);
            }
        }

        return(maxNum);
    }
Example #5
0
    private static string GetBundleAssetsListMD5(BundleData bundle)
    {
        var str = string.Join(string.Empty, bundle.includeGUIDs.ToArray()) +
                  string.Join(string.Empty, bundle.GetExtraData().dependGUIDs.ToArray());

        return(ZipFile.md5.getMd5Hash(System.Text.Encoding.ASCII.GetBytes(str)));
    }
Example #6
0
    public static bool BuildSingleBundle(BundleData bundle)
    {
        UnityEngine.Object assetObj   = null;
        string             outputPath = GenerateOutputBundlePath(bundle.name);

        if (!LoadAssetObjectByAssetPath(bundle.assetPath, out assetObj))
        {
            return(false);
        }

        uint crc       = 0;
        long changTime = DateTime.Now.ToBinary();

        bool succeed = BuildAssetBundle(assetObj, outputPath, out crc);

        BundleBuildState bundleState = BundleManager.GetBuildStateNoNull(bundle.assetPath);

        if (succeed)
        {
            bundleState.crc = crc;
            bundleState.lastDependencies = bundle.depends.ToArray();
            FileInfo info = new FileInfo(outputPath);
            bundleState.size       = info.Length;
            bundleState.changeTime = changTime;
        }
        else
        {
            bundleState.lastDependencies = null;
        }

        //  每次写入,文件过多会有性能问题
        //BMDataAccessor.SaveBundleBuildeStates();
        return(succeed);
    }
Example #7
0
        //创建bundle数据
        BundleData CreateBdlData(string bundle_id)
        {
            BdlCfgInfo bdlCfg = AbsResConfig.GetBdlCfg(bundle_id);
            string     url    = bdlCfg.path; //修正路径(已经是小写)
            //url = url.ToLower();

            AssetData data;

            if (m_url2data.TryGetValue(url, out data))
            {
                return(data as BundleData);
            }

            BundleData bdlData = new BundleData();

            bdlData.Init(url);

            if (bdlCfg.depends != null)
            {
                //有依赖项
                BundleData dpData;
                for (int i = 0; i < bdlCfg.depends.Length; ++i)
                {
                    dpData = CreateBdlData(bdlCfg.depends[i].id);
                    bdlData.AddDepend(dpData);
                }
            }

            bdlData.active_time = DateUtil.TimeFromStart;

            m_url2data[url] = bdlData;

            return(bdlData);
        }
        private string GetAssemblyFullPath(IAssemblyMetadata metadata)
        {
            BundleData member = this.FrameworkAdaptor.InstalledBundles.Find(a => a.SymbolicName == metadata.Owner.SymbolicName);

            AssertUtility.NotNull(member);
            return(BundleUtility.FindAssemblyFullPath(member.Path, metadata.Path, true));
        }
Example #9
0
    /**
     * Add a path to bundle's include list.
     * @param path The path must be a path under Asset. Can be path of diretory or file.
     * @param bundleName The bundle's name.
     */
    public static void AddPathToBundle(string path, string bundleName)
    {
        BundleData bundle = GetBundleData(bundleName);

        //������ӵĴ���
        if (bundle.bundleRelativePath == "" || bundle == null)
        {
            bundle.bundleRelativePath = path.Substring(0, path.LastIndexOf("/"));
        }
        //������ӵĴ���


        if (IsNameDuplicatedAsset(bundle, path))
        {
            Debug.LogWarning("Name of new add asset will be duplicate with asset in bundle " + bundleName + ". This may cause problem when you trying to load them.");
        }

        string guid = AssetDatabase.AssetPathToGUID(path);

        bundle.includeGUIDs.Add(guid);

        AddIncludeRef(guid, bundle);
        RefreshBundleDependencies(bundle);
        UpdateBundleChangeTime(bundle.name);

        BMDataAccessor.SaveBundleData();
    }
Example #10
0
        /// <summary>
        /// 将插件本地程序集添加到ASP.NET页面预编译引用程序集列表。这个方法一般是内部使用。
        /// </summary>
        /// <param name="bundleSymbolicName">插件唯一名称。</param>
        /// <returns>返回插件所有本地程序集。</returns>
        public virtual ICollection <Assembly> AddReferencedAssemblies(string bundleSymbolicName)
        {
            //Check if this bundle still exist or not.
            BundleData bundleData = BundleRuntime.Instance.GetFirstOrDefaultService <IBundleInstallerService>().GetBundleDataByName(bundleSymbolicName);

            if (bundleData == null)
            {
                FileLogUtility.Debug(string.Format("Bundle '{0}' does not exist when trying to add its assemblies to referenced assemblies.",
                                                   bundleSymbolicName));
                return(new List <Assembly>());
            }

            using (ReaderWriterLockHelper.CreateReaderLock(CacheLock))
            {
                //already registered its assembiles
                ICollection <Assembly> registeredItems;
                if (RegisteredBunldeCache.TryGetValue(bundleData, out registeredItems))
                {
                    return(registeredItems);
                }

                IServiceManager serviceContainer = BundleRuntime.Framework.ServiceContainer;
                IRuntimeService service          = serviceContainer.GetFirstOrDefaultService <IRuntimeService>();
                List <Assembly> assemlbies       = service.LoadBundleAssembly(bundleSymbolicName);
                FileLogUtility.Debug(string.Format("Add the assemblies of bundle '{0}' to top level referenced assemblies.", bundleSymbolicName));
                assemlbies.ForEach(AddReferencedAssembly);
                //cache the assemblies
                using (ReaderWriterLockHelper.CreateWriterLock(CacheLock))
                {
                    RegisteredBunldeCache[bundleData] = assemlbies;
                }

                return(assemlbies);
            }
        }
Example #11
0
    //
    public static void ShowBundle(BundleData newBundle)
    {
        // Show dummy object in inspector
        if (sbInspectorObj == null)
        {
            sbInspectorObj           = ScriptableObject.CreateInstance <SceneBundleInpectorObj>();
            sbInspectorObj.hideFlags = HideFlags.DontSave;
        }

        if (abInpsectorObj == null)
        {
            abInpsectorObj           = ScriptableObject.CreateInstance <AssetBundleInspectorObj>();
            abInpsectorObj.hideFlags = HideFlags.DontSave;
        }

        if (newBundle != null)
        {
            Selection.activeObject = newBundle.sceneBundle? (Object)sbInspectorObj : (Object)abInpsectorObj;
        }
        else
        {
            Selection.activeObject = null;
        }

        // Update bundle
        if (newBundle == currentBundle)
        {
            return;
        }

        currentBundle = newBundle;

        Refresh();
    }
Example #12
0
        private void context_BundleStateChanged(object sender, BundleStateChangedEventArgs e)
        {
            BundleRuntime runtime    = BundleRuntime.Instance;
            BundleData    bundleData = runtime.GetFirstOrDefaultService <IBundleInstallerService>()
                                       .GetBundleDataByName(e.Bundle.SymbolicName);

            if (bundleData == null)
            {
                return;
            }

            bool needLoad = e.CurrentState == BundleState.Active;

            if (needLoad)
            {
                RegisterBundle(e.Bundle);
            }
            else if (e.CurrentState == BundleState.Stopping)
            {
                //如果插件正在停止,就不需要更新ContainerBuilder了,因为这个服务即将不可用。
                if (BundleRuntime.Instance.State == BundleRuntimeState.Stopping)
                {
                    return;
                }
                Assembly[] assemblies;
                if (_registerHostory.TryGetValue(e.Bundle.BundleID, out assemblies))
                {
                    IServiceResolver newResolver = UnRegisterBundleAndGetControllerResolver(assemblies);
                    ServiceResolver = newResolver;
                }
            }
        }
Example #13
0
    static void TraceBundleInfo(BundleData bundleData, int treeDepth, ref string log)
    {
        return;

        string empty = "";

        for (int i = 0; i < treeDepth; i++)
        {
            empty += "   ";
        }

        log = log + empty + bundleData.name + " include : ";

        foreach (string include in bundleData.includs)
        {
            log = log + include + "  ";
        }

        log = log + "\n";

        treeDepth += 1;

        int childCount = bundleData.children.Count;

        if (childCount != 0)
        {
            for (int i = childCount - 1; i >= 0; i--)
            {
                TraceBundleInfo(_treedBundleDatas[bundleData.children[i]], treeDepth, ref log);
            }
        }
    }
Example #14
0
    internal static bool BuildBundleTree(BundleData bundle, List <string> requiredBuildList)
    {
        BuildPipeline.PushAssetDependencies();

        bool succ = false;

        if (bundle.name.StartsWith("+"))
        {
            succ = true;
            EB.Debug.Log("Skip Folder Node {0}", bundle.name);
        }
        else
        {
            succ = BuildSingleBundle(bundle);
            if (!succ)
            {
                EB.Debug.LogError("{0} build failed.", bundle.name);
                BuildPipeline.PopAssetDependencies();
                return(false);
            }
            else
            {
                EB.Debug.Log("{0} build succeed.", bundle.name);
            }
        }

        foreach (string childName in bundle.children)
        {
            BundleData child = BundleManager.GetBundleData(childName);
            if (child == null)
            {
                EB.Debug.LogError("Cannnot find bundle [{0}]. Sth wrong with the bundle config data.", childName);
                BuildPipeline.PopAssetDependencies();
                return(false);
            }

            bool isDependingBundle = false;
            foreach (string requiredBundle in requiredBuildList)
            {
                if (BundleManager.IsBundleDependOn(requiredBundle, childName))
                {
                    isDependingBundle = true;
                    break;
                }
            }

            if (isDependingBundle || !BuildConfiger.DeterministicBundle)
            {
                succ = BuildBundleTree(child, requiredBuildList);
                if (!succ)
                {
                    BuildPipeline.PopAssetDependencies();
                    return(false);
                }
            }
        }

        BuildPipeline.PopAssetDependencies();
        return(true);
    }
Example #15
0
        public IBundle InstallBundle(string location, Stream stream)
        {
            IBundle bundle = Framework.Bundles.GetBundle(location);

            if (bundle == null)
            {
                BundleData bundleData = Framework.ServiceContainer.GetFirstOrDefaultService <IBundleInstallerService>().CreateBundleData(location, stream);
                if (bundleData == null)
                {
                    Framework.EventManager.DispatchFrameworkEvent(this, new FrameworkEventArgs(FrameworkEventType.Error, new Exception($"Install bundle in '{location}' failed.")));
                    return(null);
                }
                Tuple <IBundle, IBundleMetadata> tuple = Framework.AddBundleData(bundleData);
                bundle = tuple.Item1;
                IBundleMetadata metadata = tuple.Item2;
                if (string.IsNullOrEmpty(bundleData.HostBundleSymbolicName))
                {
                    Interface1 host = metadata as Interface1;
                    AssertUtility.IsTrue(host != null);
                    List <IFragmentBundleMetadata> metadatas = BundleUtility.GetMetadatas <IFragmentBundleMetadata>(Framework.FrameworkAdaptor.State.Bundles);
                    BundleUtility.BindFragmentMetadatas(host, metadatas);
                }
                else
                {
                    IFragmentBundleMetadata metadata2 = metadata as IFragmentBundleMetadata;
                    AssertUtility.IsTrue(metadata2 != null);
                    BundleUtility.GetMetadatas <Interface1>(Framework.FrameworkAdaptor.State.Bundles);
                }
                Framework.ServiceContainer.GetFirstOrDefaultService <IBundlePersistent>().SaveInstallLocation(location);
            }
            return(bundle);
        }
Example #16
0
        /// <summary>
        /// 注册组件
        /// </summary>
        /// <param name="location">位置</param>
        /// <returns>IBundle</returns>
        /// <exception cref="Syncfusion.Addin.BundleException"></exception>
        /// <exception cref="System.IO.FileNotFoundException"></exception>
        public IBundle InstallBundle(String location)
        {
            if (!ValidExtention(location))
            {
                location = location + BundleExtention[0];
            }

            string fullLocation = string.Empty;

            bool isPathRooted = Path.IsPathRooted(location);

            if (isPathRooted)
            {
                fullLocation = location;
            }

            if (!File.Exists(fullLocation))
            {
                throw new BundleException(String.Format("Bundle {0} not found.", location),
                                          new FileNotFoundException(String.Format("file:{0} not found.", fullLocation)));
            }

            // Create the bundle object
            BundleData bundleData = new BundleData();

            bundleData.Id       = _bundleRepository.Count;
            bundleData.Location = fullLocation;
            Bundle bundle = new Bundle(bundleData, this);

            if (CheckInstallBundle(bundle))
            {
                InstallBundleInternal(bundle);
            }
            return(bundle);
        }
Example #17
0
    /**
     * Test if path can be added to bundle.
     * @param path The path must be a path under Asset. Can be path of diretory or file.
     * @param bundleName The bundle's name.
     */
    public static bool CanAddPathToBundle(string path, string bundleName)
    {
        if (bundleName.StartsWith("+"))
        {
            return(false);
        }

        BundleData bundle = GetBundleData(bundleName);

        if (bundle == null || Path.IsPathRooted(path) || (!File.Exists(path) && !Directory.Exists(path)))
        {
            return(false);
        }

        string guid = AssetDatabase.AssetPathToGUID(path);

        if (bundle.includeGUIDs.Contains(guid))
        {
            return(false);
        }

        if (ContainsFileInPath(path, sceneDetector) && !bundle.sceneBundle)
        {
            return(false);
        }
        else if (ContainsFileInPath(path, assetDetector) && bundle.sceneBundle)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Example #18
0
        private void BundleEventListener(object sender, BundleStateChangedEventArgs e)
        {
            Action <ServiceData> action = null;
            IBundle             bundle;
            Func <string, Type> loadClass;
            bool       flag             = e.CurrentState == BundleState.Starting;
            BundleData bundleDataByName = this._framework.ServiceContainer.GetFirstOrDefaultService <IBundleInstallerService>().GetBundleDataByName(e.Bundle.SymbolicName);

            if (bundleDataByName != null)
            {
                bundle = this._framework.GetBundleBySymbolicName(bundleDataByName.SymbolicName);
                AssertUtility.NotNull(bundle);
                loadClass = classType => bundle.LoadClass(classType);
                if (flag)
                {
                    if (action == null)
                    {
                        action = serviceData => this.AddService(bundle, serviceData, loadClass);
                    }
                    bundleDataByName.Services.ForEach(action);
                }
                else if (e.CurrentState == BundleState.Stopping)
                {
                    this.RemoveServiceByOwner(bundle);
                }
            }
        }
Example #19
0
	//
	public static void ShowBundle(BundleData newBundle)
	{
		// Show dummy object in inspector
		if(sbInspectorObj == null)
		{
			sbInspectorObj = ScriptableObject.CreateInstance<SceneBundleInpectorObj>();
			sbInspectorObj.hideFlags = HideFlags.DontSave;
		}

		if(abInpsectorObj == null)
		{
			abInpsectorObj = ScriptableObject.CreateInstance<AssetBundleInspectorObj>();
			abInpsectorObj.hideFlags = HideFlags.DontSave;
		}

		if(newBundle != null)
			Selection.activeObject = newBundle.sceneBundle? (Object)sbInspectorObj : (Object)abInpsectorObj;
		else
			Selection.activeObject = null;
		
		// Update bundle
		if(newBundle == currentBundle)
			return;
		
		currentBundle = newBundle;
		
		Refresh();
	}
Example #20
0
    //当需要一个依赖包,但是此依赖包还未加载成功,可能未加载,也可能正在加载之中时调用
    //当一个依赖包正在加载之时,此时如果请求此依赖包,则进行依赖登记,加需要之后加载的资源名登记在list中
    public static void AddWattingThisDependent(BundleData bundle, BundleRequest waitedRequest)
    {
        if (!CurrentLoadingDependent.ContainsKey(waitedRequest))
        {
            Log.E(ELogTag.ResourceSys, waitedRequest.Url + "Is not loading!");
            return;
        }

        //直接将依赖的资源提取出来进行登记
        List <string> regDependList     = CurrentLoadingDependent[waitedRequest];
        List <string> dependIncludeList = waitedRequest.bundleData.includs;

        if (bundle == null || bundle.dependAssets == null)
        {
            Log.E(ELogTag.ResourceSys, "Bundle dependAssets is null");
        }

        List <string> bundleDependList = bundle.dependAssets;

        int bundleDependCount = bundleDependList.Count;

        for (int i = 0; i < bundleDependCount; i++)
        {
            string fileName = CommonTools.GetPathFileName(bundleDependList[i]);

            if (!regDependList.Contains(fileName) &&
                dependIncludeList.Contains(bundleDependList[i]))
            {
                regDependList.Add(fileName);
            }
        }
    }
Example #21
0
        private void BundleEventHandler(object sender, BundleStateChangedEventArgs e)
        {
            bool flag = e.CurrentState == BundleState.Starting;
            IBundleInstallerService firstOrDefaultService = this._framework.ServiceContainer.GetFirstOrDefaultService <IBundleInstallerService>();
            BundleData bundleDataByName = firstOrDefaultService.GetBundleDataByName(e.Bundle.SymbolicName);

            if (bundleDataByName != null)
            {
                if (flag)
                {
                    this.AddExtensionPoint(e.Bundle, bundleDataByName.ExtensionPoints);
                    this.AddExtension(e.Bundle, bundleDataByName.Extensions);
                    Interface1 bundleByID = this._framework.FrameworkAdaptor.State.GetBundleByID(e.Bundle.BundleID) as Interface1;
                    if (bundleByID != null)
                    {
                        BundleData data2 = null;
                        foreach (IFragmentBundleMetadata metadata in bundleByID.Fragments)
                        {
                            data2 = firstOrDefaultService.GetBundleDataByName(metadata.SymbolicName);
                            this.AddExtensionPoint(e.Bundle, data2.ExtensionPoints);
                            this.AddExtension(e.Bundle, data2.Extensions);
                        }
                    }
                }
                else if (e.CurrentState == BundleState.Stopping)
                {
                    this.ReleaseExtension(e.Bundle);
                }
            }
        }
Example #22
0
    bool GUI_TreeItem(int indent, string bundleName)
    {
        if (!m_CurrentShowingBundles.Contains(bundleName))
        {
            m_CurrentShowingBundles.Add(bundleName);
        }

        BundleData bundleData = BundleManager.GetBundleData(bundleName);

        if (bundleData == null)
        {
            Debug.LogError("Cannot find bundle : " + bundleName);
            return(true);
        }

        Rect itemRect = GUI_DrawItem(bundleData, indent);

        EditProcess(itemRect, bundleData.name);

        if (DragProcess(itemRect, bundleData.name))
        {
            return(false);
        }

        SelectProcess(itemRect, bundleData.name);

        if (m_CurrentEditing != bundleData.name)
        {
            RightClickMenu(itemRect);
        }

        return(GUI_DrawChildren(bundleData.name, indent));
    }
Example #23
0
    public static void ArangeDependent(List <string> assetFolder, string categre)
    {
        _orignalBundleDatas.Clear();
        _dependAssetNum.Clear();
        commonBundleData = null;
        _treedBundleDatas.Clear();

        _currentCategre = categre;

        //collect all asset
        List <Object> assetObjects = new List <Object>();

        foreach (var folder in assetFolder)
        {
            assetObjects.AddRange(Resources.LoadAll(folder));
        }

        // 找到每个资源的依赖
        CreateAllBundleData(assetObjects.ToArray());

        // 统计每个被依赖资源的被依赖次数
        GetDependentNum();

        // 创建公共AssetBundle,按照被依赖的次数,形成单个链条
        MakeNumBundleTree();

        // 将我们的资源AssetBundle插入到公共AssetBundle中
        InsertBundleToNumTree();

        CreateBundle(commonBundleData, "");
    }
Example #24
0
    internal static void AddTreeDependRefs(string guid, BundleData bundle, Dictionary <string, List <BundleData> > treeDependRefDict)
    {
        if (GetParentNode(bundle) != null)
        {
            if (IsIncludeOrExIncludeInParent(guid, GetBundleData(bundle.parent)))
            {
                return;
            }
        }

        if (!treeDependRefDict.ContainsKey(guid))
        {
            List <BundleData> sharedBundleList = new List <BundleData>();
            sharedBundleList.Add(bundle);
            treeDependRefDict.Add(guid, sharedBundleList);
        }
        else
        {
            if (!treeDependRefDict[guid].Contains(bundle))
            {
                treeDependRefDict[guid].Add(bundle);
            }
        }

        AdjustExIncludeGUIDs(guid, treeDependRefDict);
    }
Example #25
0
        public static void BuildUniScriptScene(string sceneBundleName, string assetBundleName)
        {
            //if (Directory.Exists("Packs"))
            //    Directory.Delete("Packs", true);

            Directory.CreateDirectory("Packs");

            var monolithPath = "Assets/UniScript/Resources/uniscript_monolith.json";

            MergeCsx.CreateMonolith(monolithPath, assetBundleName);

            var resourceMapPath = "Assets/UniScript/Resources/uniscript_resource_map.json";
            var resourceMap     = UniMigration.GenerateResourceMap();

            File.WriteAllText(resourceMapPath, JsonConvert.SerializeObject(resourceMap));
            AssetDatabase.ImportAsset(resourceMapPath);
            AssetImporter.GetAtPath(resourceMapPath).SetAssetBundleNameAndVariant(assetBundleName, "");

            var randId = System.DateTime.Now.GetHashCode().ToString();
            var mf     = BuildPipeline.BuildAssetBundles("./Packs/", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);

            foreach (var name in mf.GetAllAssetBundles())
            {
                var hash       = mf.GetAssetBundleHash(name);
                var id         = name;
                var bundleData = new BundleData()
                {
                    hash = hash.ToString(), id = id
                };
                File.WriteAllText("./Packs/" + name + ".json", JsonUtility.ToJson(bundleData));
            }

            File.Delete(monolithPath);
            File.Delete(resourceMapPath);
        }
Example #26
0
    IEnumerator LoadBundleAsync(string assetName, Action <UObject> action = null)
    {
        if (m_BundleInfos.ContainsKey(assetName))
        {
            string        bundleName  = m_BundleInfos[assetName].BundleName;
            string        bundlePath  = Path.Combine(PathUtil.BundleResourcePath, bundleName);
            List <string> dependences = m_BundleInfos[assetName].Dependences;
            BundleData    bundle      = GetBundle(bundleName);
            if (bundle == null)
            {
                UObject obj = Manager.Pool.Spawn("AssetBundle", bundleName);
                if (obj != null)
                {
                    AssetBundle ab = obj as AssetBundle;
                    bundle = new BundleData(ab);
                }
                else
                {
                    AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(bundlePath);
                    yield return(request);

                    bundle = new BundleData(request.assetBundle);
                }
                m_AssetBundles.Add(bundleName, bundle);
            }

            if (dependences != null && dependences.Count > 0)
            {
                for (int i = 0; i < dependences.Count; ++i)
                {
                    yield return(LoadBundleAsync(dependences[i]));
                }
            }

            if (assetName.EndsWith(".unity"))
            {
                action?.Invoke(null);
                yield break;
            }

            // 当加载的是依赖资源时没有回调,直接退出
            if (action == null)
            {
                yield break;
            }

            AssetBundleRequest bundleRequest = bundle.bundle.LoadAssetAsync(assetName);
            yield return(bundleRequest);

            /*if (action != null && bundleRequest != null)
             * {
             *  action.Invoke(bundleRequest.asset);
             * }*/
            action?.Invoke(bundleRequest?.asset);
        }
        else
        {
            Debug.LogError("缺少文件: " + assetName);
        }
    }
Example #27
0
    IEnumerator DownloadAssetBundleThenCache(BundleData bundleData, Action <string> completed)
    {
        var    bundleName = bundleData.bundleName;
        string url        = GetFileProtocolUrlForAssetBundle(bundleName);
        uint   crc        = bundleData.crc;

        // get AssetBundle from file path.
        using (var www = WWW.LoadFromCacheOrDownload(url, FIXED_CACHED_SLOT_VERSION, crc)) {        // use fixed version parameter. it's not version, only SLOT.
            yield return(www);

            if (!String.IsNullOrEmpty(www.error))
            {
                Debug.LogError("DownloadAssetBundleThenCache www.error:" + www.error);
                yield break;
            }

            var assetBundle = www.assetBundle;

            // release AssetBundle resource now.
            assetBundle.Unload(false);
        }

        while (!Caching.IsVersionCached(url, FIXED_CACHED_SLOT_VERSION))          // use fixed version parameter. it's not version, only SLOT.
        // wait for cached.
        {
            yield return(null);
        }

        completed(bundleName);
    }
    IEnumerator DownloadBundle(string ContentName, BundleData CurrentBundle)
    {
        Debug.Log("Downloading Bundle " + CurrentBundle._Name);
        string url = "https://soleilrouge.herokuapp.com/Games/DownloadBundleGet/?platform=" +
                     EngineInstance.GetPlatformName() + "&name=" + CurrentBundle._Url + "&version=" + CurrentBundle._Version;

        Debug.Log("Url = [" + url + "]");
        //Request.redirectLimit = 1;
        _Request = UnityWebRequest.Get(url);

        yield return(_Request.SendWebRequest());

        //_AssetStatus = new WWW (url);
        //yield return _AssetStatus;
        if (_Request.isNetworkError || _Request.isHttpError)
        {
            Debug.LogWarning("Erreur: Impossible de télécharger le Bundle");
            ShowDownloadErrorPanel();
        }
        else
        {
            Directory.CreateDirectory(PathBuilder.GetContentFolder(ContentName));
            Debug.Log("Writing Bundle [" + PathBuilder.GetBundleFile(ContentName, CurrentBundle._Name) + "]");
            System.IO.File.WriteAllBytes(PathBuilder.GetBundleFile(ContentName, CurrentBundle._Name), _Request.downloadHandler.data);
            yield return(1);

            HideDownloadBundle();
            CheckLoadBundles();
        }
    }
Example #29
0
    IEnumerator DownloadAssetBundleThenCache2(BundleData bundleData, Action <string> completed)
    {
        var    bundleName = bundleData.bundleName;
        string url        = GetFileProtocolUrlForAssetBundle(bundleName);
        int    version    = bundleData.version;
        uint   crc        = bundleData.crc;

        // AssetBundleをファイルプロトコルで取得
        var www = WWW.LoadFromCacheOrDownload(url, version, crc);

        yield return(www);

        if (!String.IsNullOrEmpty(www.error))
        {
            Debug.LogError("DownloadAssetBundleThenCache2 www.error:" + www.error);
            yield break;
        }

        while (!Caching.IsVersionCached(url, version))
        {
            // 重量のあるリソースだと、キャッシュまでに時間がかかるので、cachedになるまで待つ
            yield return(null);
        }
        var assetBundle = www.assetBundle;

        // assetBundleを開放
        assetBundle.Unload(false);

        www.Dispose();

        completed(bundleName);
    }
Example #30
0
    private IEnumerator HotUpdate()
    {
        Debug.Log("begin hot update");
        List <BundleData> updateFileList = new List <BundleData>();

        Debug.Log("download version file");
        /////// Download Version File ///////
        string serverVersionFilePath = Utils.HttpDataPath() + "assetbundle.txt";
        WWW    serverVersionFile     = new WWW(serverVersionFilePath);

        yield return(serverVersionFile);

        List <BundleData> serverBundleList = LitJson.JsonMapper.ToObject <List <BundleData> >(serverVersionFile.text);

        string            localVersionFilePath             = Utils.RealPath("assetbundle.txt");
        StreamReader      localVersionFile                 = File.OpenText(localVersionFilePath);
        List <BundleData> localBundleList                  = LitJson.JsonMapper.ToObject <List <BundleData> >(localVersionFile.ReadToEnd());
        Dictionary <string, BundleData> localBundleMapping = new Dictionary <string, BundleData>();

        Debug.Log("update file list");
        /////// Get Update File List ///////
        foreach (BundleData bundle in localBundleList)
        {
            localBundleMapping[bundle.name] = bundle;
        }

        foreach (BundleData bundle in serverBundleList)
        {
            if (localBundleMapping.ContainsKey(bundle.name))
            {
                BundleData localBundle = localBundleMapping[bundle.name];
                if (localBundle.md5 != bundle.md5)
                {
                    updateFileList.Add(bundle);
                }
            }
            else
            {
                updateFileList.Add(bundle);
            }
        }


        Debug.Log("download bundle file");
        /////// Download Bundle File ///////
        foreach (BundleData bundle in updateFileList)
        {
            Debug.Log(bundle.name);
            string serverBundlePath = Utils.HttpDataPath() + bundle.name + ".assetbundle";
            WWW    serverBundleFile = new WWW(serverBundlePath);
            yield return(serverBundleFile);

            Utils.SaveFile(serverBundleFile.bytes, Utils.PresistentDataPath() + bundle.name + ".assetbundle");
            serverBundleFile.Dispose();
        }

        Utils.SaveFile(serverVersionFile.bytes, Utils.PresistentDataPath() + "assetbundle.txt");
        serverVersionFile.Dispose();
    }
Example #31
0
 public SystemBundle(Framework framework) : base(data, framework)
 {
     BundleData data = new BundleData {
         SymbolicName = "UIShell.OSGi.SystemBundle",
         Version      = FrameworkConstants.DEFAULT_VERSION,
         Name         = "SystemBundle"
     };
 }
Example #32
0
    /**
     * Detect if the bundle need update.
     */
    public static bool IsBundleNeedBunild(BundleData bundle)
    {
        string outputPath = GenerateOutputPathForBundle(bundle);
        if (!File.Exists(outputPath))
        {
            Debug.LogWarning("BundleData : " + bundle.name + " Not Exsit!  ");
            return true;
        }

        BundleBuildState bundleBuildState = BundleManager.GetBuildStateOfBundle(bundle.name);
        if (bundleBuildState == null)
        {
            Debug.LogWarning("BundleData : " + bundle.name + " Not Found!  ");
            return true;
        }
        DateTime lastBuildTime = File.GetLastWriteTime(outputPath);
        DateTime bundleChangeTime = bundleBuildState.changeTime == -1 ? DateTime.MaxValue : DateTime.FromBinary(bundleBuildState.changeTime);
        if (System.DateTime.Compare(lastBuildTime, bundleChangeTime) < 0)
        {
            Debug.LogWarning("BundleData : " + bundle.name + " bundleChangeTime > lastBuildTime ");
            return true;
        }

        string[] assetPaths = GetAssetsFromPaths(BundleManager.GUIDsToPaths(bundle.includeGUIDs.ToArray()), bundle.sceneBundle);
        string[] dependencies = AssetDatabase.GetDependencies(assetPaths);
        if (!EqualStrArray(dependencies, bundleBuildState.lastBuildDependencies))
        {
            Debug.LogWarning("BundleData : " + bundle.name + " Build depenedencies list changed: ");
            return true; // Build depenedencies list changed.
        }

        foreach (string file in dependencies)
        {
            if (DateTime.Compare(lastBuildTime, File.GetLastWriteTime(file)) < 0)
            {
                Debug.LogWarning("BundleData : " + bundle.name + " file changed : " + file);
                return true;
            }
        }

        if (bundle.parent != "")
        {
            BundleData parentBundle = BundleManager.GetBundleData(bundle.parent);
            if (parentBundle != null)
            {
                if (IsBundleNeedBunild(parentBundle))
                    return true;
            }
            else
            {
                Debug.LogError("Cannot find bundle");
            }
        }

        return false;
    }
Example #33
0
    Rect GUI_DrawItem(BundleData bundle, int indent)
    {
        bool isEditing = m_CurrentEditing == bundle.name;
        bool isRecieving = m_CurrentRecieving == bundle.name;
        bool isSelected = m_Selections.Contains(bundle.name);

        GUIStyle currentLableStyle = BMGUIStyles.GetCustomStyle("TreeItemUnSelect");
        if (isRecieving)
            currentLableStyle = BMGUIStyles.GetCustomStyle("receivingLable");
        else if (isSelected && !isEditing)
            currentLableStyle = HasFocuse() ? BMGUIStyles.GetCustomStyle("TreeItemSelectBlue") : BMGUIStyles.GetCustomStyle("TreeItemSelectGray");

        Rect itemRect = EditorGUILayout.BeginHorizontal(currentLableStyle);

        if (bundle.children.Count == 0)
        {
            GUILayout.Space(m_IndentWidth * indent + m_NoToggleIndent);
        }
        else
        {
            GUILayout.Space(m_IndentWidth * indent);
            bool fold = !GUILayout.Toggle(!IsFold(bundle.name), "", BMGUIStyles.GetCustomStyle("Foldout"));
            SetFold(bundle.name, fold);
        }

        GUILayout.Label(bundle.sceneBundle ? BMGUIStyles.GetIcon("sceneBundleIcon") : BMGUIStyles.GetIcon("assetBundleIcon"), BMGUIStyles.GetCustomStyle("BItemLabelNormal"), GUILayout.ExpandWidth(false));

        if (!isEditing)
        {
            GUILayout.Label(bundle.name, isSelected ? BMGUIStyles.GetCustomStyle("BItemLabelActive") : BMGUIStyles.GetCustomStyle("BItemLabelNormal"));
        }
        else
        {
            GUI.SetNextControlName(m_EditTextFeildName);
            m_EditString = GUILayout.TextField(m_EditString, BMGUIStyles.GetCustomStyle("TreeEditField"));
        }

        EditorGUILayout.EndHorizontal();

        return itemRect;
    }
Example #34
0
 private static void AddCommonDepends(BundleData bundleData)
 {
     bundleData.depends.Add("Assets/LocalResources/Shader.prefab");
 }
Example #35
0
 private static BundleData CreateBundleData(string path)
 {
     BundleData data = new BundleData();
     data.assetPath = path;
     data.name = Path.GetFileNameWithoutExtension(path);
     data.guid = AssetDatabase.AssetPathToGUID(path);
     data.depends = BuildHelp.GetDependencies(path);
     return data;
 }
Example #36
0
 private static BundleDependsData CreateDependsData(BundleData data)
 {
     BundleDependsData dependsData = new BundleDependsData();
     dependsData.depends = new string[data.depends.Count];
     for (int i = 0; i < data.depends.Count; i++)
     {
         dependsData.depends[i] = Path.GetFileNameWithoutExtension(data.depends[i]);
     }
     dependsData.name = data.name;
     return dependsData;
 }
Example #37
0
 static public void AddNewBundleData( BundleData data )
 {
     Instance.mBundleData.Add(data.assetPath, data);
 }
Example #38
0
        public void Process_AddBundle()
        {
            BundleData entry = new BundleData();
            UrlAliasInfo urlAliasInfo = new UrlAliasInfo();

            entry = (BundleData)Process_GetEntryAddValues(entry);

            entry.BundledItems = Process_GetBundledItems();

            urlAliasInfo = Process_Alias();

            try
            {
                if (hdn_publishaction.Value == Convert.ToInt32(EkEnumeration.AssetActionType.Save).ToString())
                {
                    m_refCatalog.AddAndSave(entry, urlAliasInfo);
                    Process_Taxonomy(entry.Id, entry.FolderId);
                    Process_Inventory(entry.Id);
                    Util_ResponseHandler("catalogentry.aspx?close=false&LangType=" + entry.LanguageId + "&id=" + entry.Id + "&type=update&back_file=cmsform.aspx&back_action=ViewStaged&back_folder_id=" + entry.FolderId + "&back_callerpage=content.aspx&back_origurl=action%3dViewContentByCategory%26id%3d" + entry.FolderId + "&back_LangType=" + entry.LanguageId + "&rnd=6"); // goes to edit screen.
                }
                else if (hdn_publishaction.Value == Convert.ToInt32(EkEnumeration.AssetActionType.Checkin).ToString())
                {
                    m_refCatalog.AddAndCheckIn(entry, urlAliasInfo);
                    Process_Taxonomy(entry.Id, entry.FolderId);
                    Process_Inventory(entry.Id);
                    Util_ResponseHandler((string)("../content.aspx?action=View&folder_id=" + entry.FolderId + "&id=" + entry.Id + "&LangType=" + entry.LanguageId + "&callerpage=content.aspx&origurl=action%3dViewContentByCategory%26id%3d" + entry.FolderId + "%26contentid%3d0%26form_id%3d0%26LangType%3d" + entry.LanguageId)); // goes to content view screen
                }
                else if (hdn_publishaction.Value == Convert.ToInt32(EkEnumeration.AssetActionType.Submit).ToString())
                {
                    m_refCatalog.AddAndPublish(entry, urlAliasInfo);
                    Process_Taxonomy(entry.Id, entry.FolderId);
                    Process_Inventory(entry.Id);
                    Util_ResponseHandler((string)("../content.aspx?action=ViewContentByCategory&id=" + this.m_iFolder.ToString())); // goes to folder
                }
            }
            catch (Exception ex)
            {
                Util_ResponseHandler((string)("../reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message) + "&LangType=" + entry.LanguageId));
            }
        }
Example #39
0
    public static void WriteDependencies2Json(string path)
    {
        List<BundleData> datas = new List<BundleData>();
        foreach (KeyValuePair<string, List<string>> kvp in dependencies)
        {
            BundleData data = new BundleData();
            string assetPath = AssetDatabase.GUIDToAssetPath(kvp.Key);
            data.name = assetPath.Replace("Assets/" + srcPath, "");
            string fullpath = string.Format("{0}/{1}/{2}", Application.dataPath, srcPath, data.name);
            data.md5 = Utils.md5file(fullpath);
            data.dependAssets = FindDependencies(kvp.Key);
            datas.Add(data);
        }

        FileStream fs = new FileStream(path, FileMode.Create);
        StreamWriter sw = new StreamWriter(fs);
        string jsonStr = JsonFormatter.PrettyPrint(LitJson.JsonMapper.ToJson(datas));
        sw.Write(jsonStr);
        sw.Flush();
        sw.Close();
        fs.Close();
    }
Example #40
0
    private static bool BuildSingleBundle(BundleData bundle)
    {
        // Prepare bundle output dictionary
        string outputPath = GenerateOutputPathForBundle(bundle);
        string bundleStoreDir = Path.GetDirectoryName(outputPath);
        if (!Directory.Exists(bundleStoreDir))
            Directory.CreateDirectory(bundleStoreDir);

        // Start build
        string[] assetPaths = GetAssetsFromPaths(BundleManager.GUIDsToPaths(bundle.includeGUIDs.ToArray()), bundle.sceneBundle);
        bool succeed = false;
        uint crc = 0;
        if (bundle.sceneBundle)
            succeed = BuildSceneBundle(assetPaths, outputPath, out crc);
        else
            succeed = BuildAssetBundle(assetPaths, outputPath, out crc);

        // Remember the assets for next time build test
        BundleBuildState buildState = BundleManager.GetOrAddBuildStateOfBundle(bundle.name);
        if (succeed)
        {
            buildState.lastBuildDependencies = AssetDatabase.GetDependencies(assetPaths);
            buildState.version++;
            if (buildState.version == int.MaxValue)
                buildState.version = 0;

            buildState.crc = crc;
            FileInfo bundleFileInfo = new FileInfo(outputPath);
            buildState.size = bundleFileInfo.Length;
        }
        else
        {
            buildState.lastBuildDependencies = null;
        }

        BMDataAccessor.SaveBundleBuildeStates();
        return succeed;
    }
Example #41
0
 private static string GenerateOutputPathForBundle(BundleData bundle)
 {
     return Path.Combine(BuildConfiger.InterpretedOutputPath, (bundle.path == "" ? "" : bundle.path) + "/" + bundle.name + "." + BuildConfiger.BundleSuffix);
 }
Example #42
0
    public static bool BuildSingleBundle( BundleData bundle)
    {
        

        UnityEngine.Object assetObj = null;
        string outputPath = GenerateOutputBundlePath(bundle.name);

        if (!LoadAssetObjectByAssetPath( bundle.assetPath, out assetObj))
        {
            return false;
        }

        uint crc = 0;
        long changTime = DateTime.Now.ToBinary();

        bool succeed = BuildAssetBundle(assetObj, outputPath, out crc);

        BundleBuildState bundleState = BundleManager.GetBuildStateNoNull(bundle.assetPath);
        if (succeed)
        {
            bundleState.crc = crc;
            bundleState.lastDependencies = bundle.depends.ToArray();
            FileInfo info = new FileInfo(outputPath);
            bundleState.size = info.Length;
            bundleState.changeTime = changTime;
        }
        else
        {
            bundleState.lastDependencies = null;
        }

        //  每次写入,文件过多会有性能问题
        //BMDataAccessor.SaveBundleBuildeStates();
        return succeed;
    }
Example #43
0
    internal static bool BuildBundleTree(BundleData bundle, List<string> requiredBuildList)
    {
        BuildPipeline.PushAssetDependencies();

        bool succ = BuildSingleBundle(bundle);
        if (!succ)
        {
            Debug.LogError(bundle.name + " build failed.");
            BuildPipeline.PopAssetDependencies();
            return false;
        }
        else
        {
            Debug.Log(bundle.name + " build succeed.");
        }

        foreach (string childName in bundle.children)
        {
            BundleData child = BundleManager.GetBundleData(childName);
            if (child == null)
            {
                Debug.LogError("Cannnot find bundle [" + childName + "]. Sth wrong with the bundle config data.");
                BuildPipeline.PopAssetDependencies();
                return false;
            }

            bool isDependingBundle = false;
            foreach (string requiredBundle in requiredBuildList)
            {
                if (BundleManager.IsBundleDependOn(requiredBundle, childName))
                {
                    isDependingBundle = true;
                    break;
                }
            }
            //ĬÈ϶¼ÊÇDeterministicBundle
            if (isDependingBundle)// || !BuildConfiger.DeterministicBundle)
            {
                succ = BuildBundleTree(child, requiredBuildList);
                if (!succ)
                {
                    BuildPipeline.PopAssetDependencies();
                    return false;
                }
            }
        }

        BuildPipeline.PopAssetDependencies();
        return true;
    }
Example #44
0
    private static bool IsNameDuplicatedAsset(BundleData bundle, string newAsset)
    {
        string newName = Path.GetFileNameWithoutExtension(newAsset);
        foreach (string guid in bundle.includeGUIDs)
        {
            string path = AssetDatabase.GUIDToAssetPath(guid);
            string file = Path.GetFileNameWithoutExtension(path);
            if (file == newName)
                return true;
        }

        return false;
    }
Example #45
0
    public static bool IsNeedBuild( BundleData bundle )
    {

        if (BuildManager.IsIgnoreState)
            return true;

        string outputPath = GenerateOutputBundlePath(bundle.name);
        if (!File.Exists(outputPath))
            return true;

        BundleBuildState bundleBuildState = BundleManager.GetBuildState(bundle.assetPath);

        if (bundleBuildState == null)
            return true;

        //  输出文件是否被修改
        DateTime lastBuildTime = File.GetLastWriteTime(outputPath);
        DateTime bundleChangeTime = bundleBuildState.changeTime == -1 ? DateTime.MaxValue : DateTime.FromBinary(bundleBuildState.changeTime);
        if ( System.DateTime.Compare(lastBuildTime, bundleChangeTime) < 0)
        {
            return true;
        }

        if (DateTime.Compare(lastBuildTime, File.GetLastWriteTime(bundle.assetPath)) < 0)
        {
            return true;
        }

        //  依赖是否改变
        if(!EqualStrArray(bundle.depends, bundleBuildState.lastDependencies))
        {
            return true;
        }


        string[] allResDepends = GetFilterCsDepends(bundle.assetPath);
        for (int i = 0; i < allResDepends.Length; i++)
        {
            var fullPaht = BundleHelp.AssetPath2FullPath(ref allResDepends[i]);

            DateTime test = File.GetLastWriteTime(fullPaht);

            if (DateTime.Compare(lastBuildTime, File.GetLastWriteTime(fullPaht)) < 0)
            {
                return true;
            }

            if (DateTime.Compare(lastBuildTime, File.GetLastWriteTime(fullPaht + ".meta")) < 0)
            {
                return true;
            }
        }

        //  依赖文件是否被改变
        //for (int i = 0; i < bundle.depends.Count; i++)
        //{

        //    //  TODO:没有检测纹理之内的资源是否变化

        //    if (!File.Exists(GenerateOutputBundlePath(Path.GetFileNameWithoutExtension(bundle.depends[i]))))
        //        return true;

        //    if (DateTime.Compare(lastBuildTime, File.GetLastWriteTime(bundle.depends[i])) < 0)
        //    {
        //        return true;
        //    }

        //    //  meta change 
        //    //  Texture Format Change
        //    if (DateTime.Compare(lastBuildTime, File.GetLastWriteTime(bundle.depends[i] + ".meta")) < 0)
        //    {
        //        return true;
        //    }
        //}

        return false;
    }
Example #46
0
 internal static void RemoveIncludeRef(string guid, BundleData bundle)
 {
     string path = AssetDatabase.GUIDToAssetPath(guid);
     foreach (string subPath in BuildHelper.GetAssetsFromPath(path, bundle.sceneBundle))
     {
         string subGuid = AssetDatabase.AssetPathToGUID(subPath);
         getInstance().includeRefDict[subGuid].Remove(bundle);
     }
 }
Example #47
0
    public static bool BuildRootBundle( BundleData bundle)
    {
        if (!IsNeedBuild(bundle))
        {
            Debug.Log(string.Format("Bundle {0} Skiped!", bundle.name));
            return true;
        }

        PushCommontDepends();

        BuildPipeline.PushAssetDependencies();
        for (int i = 0; i < bundle.depends.Count; i++)
        {
            BundleData dependBundle = BundleManager.GetBundleData(bundle.depends[i]);
            if (!BuildSingleBundle(dependBundle))
            {
                Debug.Log(string.Format("Build {0} Fail!", dependBundle.name));
                goto ONE_POP;
            }
        }

        BuildPipeline.PushAssetDependencies();

        BundleData mainBundle = BundleManager.GetBundleData(bundle.assetPath);
        if ( !BuildSingleBundle(mainBundle))
        {
            goto TWO_POP;
        }

        goto SUCCEED;


    ONE_POP:
        Debug.Log( string.Format("{0} Depends Build Error! ", bundle.name));
        BuildPipeline.PopAssetDependencies();
        PopCommontDepends();
        return false;
    TWO_POP:
        Debug.Log(string.Format("{0} Self Build Error! ", bundle.name));
        BuildPipeline.PopAssetDependencies();
        BuildPipeline.PopAssetDependencies();
        PopCommontDepends();
        return false;
    SUCCEED:
        Debug.Log(string.Format("Build {0} Succeed!", bundle.name));
        BuildPipeline.PopAssetDependencies();
        BuildPipeline.PopAssetDependencies();
        PopCommontDepends();
        return true;
    }
Example #48
0
    internal static void RefreshBundleDependencies(BundleData bundle)
    {
        // Get all the includes files path
        string[] files = BuildHelper.GetAssetsFromPaths(GUIDsToPaths(bundle.includeGUIDs).ToArray(), bundle.sceneBundle);
        string[] dependGUIDs = PathsToGUIDs(AssetDatabase.GetDependencies(files));

        List<string> oldMetaList = bundle.dependGUIDs;
        bundle.dependGUIDs = new List<string>(dependGUIDs);
        bundle.dependGUIDs.RemoveAll(x => bundle.includeGUIDs.Contains(x));

        // Remove the old ones
        foreach (string guid in oldMetaList)
        {
            if (getInstance().dependRefDict.ContainsKey(guid))
                getInstance().dependRefDict[guid].Remove(bundle);
        }

        // Add new asset connection
        foreach (string guid in bundle.dependGUIDs)
        {
            if (!getInstance().dependRefDict.ContainsKey(guid))
            {
                List<BundleData> sharedBundleList = new List<BundleData>();
                sharedBundleList.Add(bundle);
                getInstance().dependRefDict.Add(guid, sharedBundleList);
            }
            else
            {
                getInstance().dependRefDict[guid].Add(bundle);
            }
        }
    }
Example #49
0
    private static void InsertBundleToBundleList(BundleData bundle)
    {
        List<BundleData> bundleList = BMDataAccessor.Bundles;
        if (bundleList.Contains(bundle))
            return;

        if (bundle.parent == "")
        {
            int childBundleStartIndex = bundleList.FindIndex(x => x.parent != "");
            childBundleStartIndex = childBundleStartIndex == -1 ? bundleList.Count : childBundleStartIndex;
            bundleList.Insert(childBundleStartIndex, bundle);
        }
        else
            bundleList.Add(bundle);
    }
Example #50
0
    /**
     * Create a new bundle.
     * @param name Name of the bundle name.
     * @param parent New parent's name. Set the parent to empty string if you want create a new root bundle.
     * @param sceneBundle Is the bundle a scene bundle?  
     */
    static public bool CreateNewBundle(string name, string parent, bool sceneBundle, string path = "")
    {
        var bundleDict = getInstance().bundleDict;

        if (bundleDict.ContainsKey(name))
            return false;

        BundleData newBundle = new BundleData();
        newBundle.name = name;
        newBundle.sceneBundle = sceneBundle;
        newBundle.path = path;
        if (parent != "")
        {
            if (!bundleDict.ContainsKey(parent))
                return false;
            else
                bundleDict[parent].children.Add(name);

            newBundle.parent = parent;
            newBundle.path = bundleDict[parent].path;
        }

        bundleDict.Add(name, newBundle);
        InsertBundleToBundleList(newBundle);

        BundleBuildState newBuildState = new BundleBuildState();
        newBuildState.bundleName = name;
        getInstance().statesDict.Add(name, newBuildState);
        BMDataAccessor.BuildStates.Add(newBuildState);

        UpdateBundleChangeTime(newBundle.name);

        BMDataAccessor.SaveBundleData();
        BMDataAccessor.SaveBundleBuildeStates();
        return true;
    }
Example #51
0
    internal static void AddIncludeRef(string guid, BundleData bundle)
    {
        string path = AssetDatabase.GUIDToAssetPath(guid);
        foreach (string subPath in BuildHelper.GetAssetsFromPath(path, bundle.sceneBundle))
        {
            string subGuid = AssetDatabase.AssetPathToGUID(subPath);

            if (!getInstance().includeRefDict.ContainsKey(subGuid))
            {
                List<BundleData> sharedBundleList = new List<BundleData>() { bundle };
                getInstance().includeRefDict.Add(subGuid, sharedBundleList);
            }
            else if (!getInstance().includeRefDict[subGuid].Contains(bundle))
            {
                getInstance().includeRefDict[subGuid].Add(bundle);
            }
        }
    }