Example #1
0
        private static AssetBundleInfo AddBundleToFolder(AssetBundleFolderInfo root, AssetBundleNameInfo nameData)
        {
            AssetBundleInfo currInfo = root.GetAssetBundleInfoByName(nameData.shortName);

            if (!System.String.IsNullOrEmpty(nameData.variant))
            {
                if (currInfo == null)
                {
                    currInfo = new BundleVariantFolderInfo(nameData.bundleName, root);
                    root.AddChild(currInfo);
                }
                var folder = currInfo as BundleVariantFolderInfo;
                if (folder == null)
                {
                    var message = "Bundle named " + nameData.shortName;
                    message += " exists both as a standard bundle, and a bundle with variants.  ";
                    message += "This message is not supported for display or actual bundle building.  ";
                    message += "You must manually fix bundle naming in the inspector.";

                    LogError(message);
                    return(null);
                }


                currInfo = folder.GetAssetBundleInfoByName(nameData.variant);
                if (currInfo == null)
                {
                    currInfo = new BundleVariantDataInfo(nameData.fullNativeName, folder);
                    folder.AddChild(currInfo);
                }
            }
            else
            {
                if (currInfo == null)
                {
                    currInfo = new BundleDataInfo(nameData.fullNativeName, root);
                    root.AddChild(currInfo);
                }
                else
                {
                    var dataInfo = currInfo as BundleDataInfo;
                    if (dataInfo == null)
                    {
                        s_InErrorState = true;
                        LogFolderAndBundleNameConflict(nameData.fullNativeName);
                    }
                }
            }
            return(currInfo);
        }
Example #2
0
        internal static AssetBundleInfo HandleConvertToVariant(BundleDataInfo bundle)
        {
            bundle.HandleDelete(true, bundle.m_Name.bundleName, kNewVariantBaseName);
            ExecuteAssetMove();
            var root = bundle.parent.GetAssetBundleInfoByName(bundle.m_Name.shortName) as BundleVariantFolderInfo;

            if (root != null)
            {
                return(root.GetAssetBundleInfoByName(kNewVariantBaseName));
            }
            else
            {
                //we got here because the converted bundle was empty.
                var vfolder = new BundleVariantFolderInfo(bundle.m_Name.bundleName, bundle.parent);
                var vdata   = new BundleVariantDataInfo(bundle.m_Name.bundleName + "." + kNewVariantBaseName, vfolder);
                bundle.parent.AddChild(vfolder);
                vfolder.AddChild(vdata);
                return(vdata);
            }
        }
Example #3
0
 internal static void HandleBundleMerge(IEnumerable <AssetBundleInfo> bundles, BundleDataInfo target)
 {
     foreach (var bundle in bundles)
     {
         bundle.HandleDelete(true, target.m_Name.bundleName, target.m_Name.variant);
     }
     ExecuteAssetMove();
 }
Example #4
0
        internal static TreeViewItem AppendBundleToTree(Model.BundleDataInfo bundle)
        {
            var itemName = bundle.m_Name.fullNativeName;
            var bunRoot  = new TreeViewItem(itemName.GetHashCode(), 0, itemName);

            var str = itemName + kSizeHeader;
            var sz  = new TreeViewItem(str.GetHashCode(), 1, kSizeHeader + bundle.TotalSize());

            str = itemName + kDependencyHeader;
            var dependency = new TreeViewItem(str.GetHashCode(), 1, kDependencyEmpty);
            var depList    = bundle.GetBundleDependencies();

            if (depList.Count > 0)
            {
                dependency.displayName = kDependencyHeader;
                foreach (var dep in bundle.GetBundleDependencies())
                {
                    str = itemName + dep.m_BundleName;
                    TreeViewItem newItem = new TreeViewItem(str.GetHashCode(), 2, dep.m_BundleName)
                    {
                        icon = Model.AssetBundleModel.bundleIcon
                    };
                    dependency.AddChild(newItem);

                    Dictionary <string, TogglePathTreeViewItem> toAssetItems = new Dictionary <string, TogglePathTreeViewItem>();

                    for (int i = 0; i < dep.m_FromAssets.Count; ++i)
                    {
                        if (!toAssetItems.TryGetValue(dep.m_ToAssets[i].fullAssetName, out TogglePathTreeViewItem item))
                        {
                            str  = itemName + dep.m_BundleName + dep.m_ToAssets[i].displayName;
                            item = new TogglePathTreeViewItem(str.GetHashCode(), 3, "/" + dep.m_ToAssets[i].displayName, "/" + dep.m_ToAssets[i].fullAssetName)
                            {
                                icon = AssetDatabase.GetCachedIcon(dep.m_ToAssets[i].fullAssetName) as Texture2D
                            };
                            newItem.AddChild(item);
                            toAssetItems.Add(dep.m_ToAssets[i].fullAssetName, item);
                        }

                        str = str + dep.m_FromAssets[i].displayName;
                        TreeViewItem refItem = new TogglePathTreeViewItem(str.GetHashCode(), 4, kReferencedPrefix,
                                                                          dep.m_FromAssets[i].displayName, dep.m_FromAssets[i].fullAssetName)
                        {
                            icon = AssetDatabase.GetCachedIcon(dep.m_FromAssets[i].fullAssetName) as Texture2D
                        };
                        item.AddChild(refItem);
                    }
                }
            }

            str = itemName + kMessageHeader;
            var msg = new TreeViewItem(str.GetHashCode(), 1, kMessageEmpty);

            if (bundle.HasMessages())
            {
                msg.displayName = kMessageHeader;
                var currMessages = bundle.GetMessages();

                foreach (var currMsg in currMessages)
                {
                    str = itemName + currMsg.message;
                    msg.AddChild(new BundleDetailItem(str.GetHashCode(), 2, currMsg.message, currMsg.severity));
                }
            }

            bunRoot.AddChild(sz);
            bunRoot.AddChild(dependency);
            bunRoot.AddChild(msg);

            return(bunRoot);
        }