Esempio n. 1
0
        public static BundleInfo FindBundle(BundleNameData name)
        {
            BundleInfo currNode = m_RootLevelBundles;

            foreach (var token in name.pathTokens)
            {
                if (currNode is BundleFolderInfo)
                {
                    currNode = (currNode as BundleFolderInfo).GetChild(token);
                    if (currNode == null)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }

            if (currNode is BundleFolderInfo)
            {
                currNode = (currNode as BundleFolderInfo).GetChild(name.shortName);
                if (currNode is BundleVariantFolderInfo)
                {
                    currNode = (currNode as BundleVariantFolderInfo).GetChild(name.variant);
                }
                return(currNode);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static bool HandleBundleRename(BundleTreeItem item, string newName)
        {
            var originalName = new BundleNameData(item.bundle.m_Name.fullNativeName);

            var findDot    = newName.LastIndexOf('.');
            var findSlash  = newName.LastIndexOf('/');
            var findBSlash = newName.LastIndexOf('\\');

            if (findDot == 0 || findSlash == 0 || findBSlash == 0)
            {
                return(false); //can't start a bundle with a / or .
            }
            bool result = item.bundle.HandleRename(newName, 0);

            if (findDot > 0 || findSlash > 0 || findBSlash > 0)
            {
                item.bundle.parent.HandleChildRename(newName, string.Empty);
            }

            ExecuteAssetMove();

            var node = FindBundle(originalName);

            if (node != null)
            {
                var message = "Failed to rename bundle named: ";
                message += originalName.fullNativeName;
                message += ".  Most likely this is due to the bundle being assigned to a folder in your Assets directory, AND that folder is either empty or only contains assets that are explicitly assigned elsewhere.";
                Debug.LogError(message);
            }

            return(result);
        }
Esempio n. 3
0
        public static BundleFolderInfo CreateEmptyBundleFolder(BundleFolderConcreteInfo folder = null)
        {
            folder = (folder == null) ? m_RootLevelBundles : folder;
            string         name     = GetUniqueName(folder) + "/dummy";
            BundleNameData nameData = new BundleNameData(folder.m_Name.bundleName, name);

            return(AddFoldersToBundle(m_RootLevelBundles, nameData));
        }
Esempio n. 4
0
        public static BundleInfo CreateEmptyVariant(BundleVariantFolderInfo folder)
        {
            string         name        = GetUniqueName(folder, k_NewVariantBaseName);
            string         variantName = folder.m_Name.bundleName + "." + name;
            BundleNameData nameData    = new BundleNameData(variantName);

            return(AddBundleToFolder(folder.parent, nameData));
        }
Esempio n. 5
0
        public static BundleInfo CreateEmptyBundle(BundleFolderInfo folder = null, string newName = null)
        {
            folder = (folder == null) ? m_rootLevelBundles : folder;
            string         name     = GetUniqueName(folder, newName);
            BundleNameData nameData = new BundleNameData(folder.m_name.BundleName, name);

            return(AddBundleToFolder(folder, nameData));
        }
Esempio n. 6
0
        private static BundleInfo AddBundleToFolder(BundleFolderInfo root, BundleNameData nameData)
        {
            BundleInfo currInfo = root.GetChild(nameData.ShortName);

            if (currInfo == null)
            {
                currInfo = new BundleDataInfo(nameData.Name, root);
                root.AddChild(currInfo);
            }
            return(currInfo);
        }
Esempio n. 7
0
        private static BundleInfo AddBundleToFolder(BundleFolderInfo root, BundleNameData nameData)
        {
            BundleInfo currInfo = root.GetChild(nameData.shortName);

            if (nameData.variant != string.Empty)
            {
                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.GetChild(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)
                    {
                        m_InErrorState = true;
                        LogError("Bundle " + nameData.fullNativeName + " has a name conflict with a bundle-folder.  Display of bundle data and building of bundles will not work.");
                    }
                }
            }
            return(currInfo);
        }
Esempio n. 8
0
        private static BundleInfo AddBundleToModel(string name)
        {
            if (name == null)
            {
                return(null);
            }

            BundleNameData nameData = new BundleNameData(name);

            BundleFolderInfo folder   = AddFoldersToBundle(m_RootLevelBundles, nameData);
            BundleInfo       currInfo = AddBundleToFolder(folder, nameData);

            return(currInfo);
        }
Esempio n. 9
0
        public static BundleInfo CreateEmptyBundle(BundleFolderInfo folder = null, string newName = null)
        {
            if ((folder as BundleVariantFolderInfo) != null)
            {
                return(CreateEmptyVariant(folder as BundleVariantFolderInfo));
            }

            folder = (folder == null) ? m_RootLevelBundles : folder;
            string         name = GetUniqueName(folder, newName);
            BundleNameData nameData;

            nameData = new BundleNameData(folder.m_Name.bundleName, name);
            return(AddBundleToFolder(folder, nameData));
        }
Esempio n. 10
0
        private static BundleFolderInfo AddFoldersToBundle(BundleFolderInfo root, BundleNameData nameData)
        {
            BundleInfo currInfo = root;
            var        size     = nameData.NameTokens.Count;

            for (var index = 0; index < size - 1; index++)
            {
                var folder = currInfo as BundleFolderInfo;
                if (folder != null)
                {
                    currInfo = folder.GetChild(nameData.NameTokens[index]);
                    if (currInfo == null)
                    {
                        currInfo = new BundleFolderInfo(nameData.NameTokens, index + 1, folder);
                        folder.AddChild(currInfo);
                    }
                }
            }
            return(currInfo as BundleFolderInfo);
        }
Esempio n. 11
0
 public BundleFolderInfo(List <string> path, int depth, BundleFolderInfo parent) : base("", parent)
 {
     m_Children        = new Dictionary <string, BundleInfo>();
     m_Name            = new BundleNameData("");
     m_Name.pathTokens = path.GetRange(0, depth);
 }
Esempio n. 12
0
 public BundleInfo(string name, BundleFolderInfo parent)
 {
     m_Name   = new BundleNameData(name);
     m_Parent = parent;
 }
Esempio n. 13
0
        private static BundleFolderConcreteInfo AddFoldersToBundle(BundleFolderInfo root, BundleNameData nameData)
        {
            BundleInfo currInfo = root;
            var        folder   = currInfo as BundleFolderConcreteInfo;
            var        size     = nameData.pathTokens.Count;

            for (var index = 0; index < size; index++)
            {
                if (folder != null)
                {
                    currInfo = folder.GetChild(nameData.pathTokens[index]);
                    if (currInfo == null)
                    {
                        currInfo = new BundleFolderConcreteInfo(nameData.pathTokens, index + 1, folder);
                        folder.AddChild(currInfo);
                    }

                    folder = currInfo as BundleFolderConcreteInfo;
                    if (folder == null)
                    {
                        m_InErrorState = true;
                        LogError("Bundle " + currInfo.m_Name.fullNativeName + " has a name conflict with a bundle-folder.  Display of bundle data and building of bundles will not work.");
                        break;
                    }
                }
            }
            return(currInfo as BundleFolderConcreteInfo);
        }
Esempio n. 14
0
        private static BundleFolderConcreteInfo AddFoldersToBundle(BundleFolderInfo root, BundleNameData nameData)
        {
            BundleInfo currInfo = root;
            var        folder   = currInfo as BundleFolderConcreteInfo;
            var        size     = nameData.pathTokens.Count;

            for (var index = 0; index < size; index++)
            {
                if (folder != null)
                {
                    currInfo = folder.GetChild(nameData.pathTokens[index]);
                    if (currInfo == null)
                    {
                        currInfo = new BundleFolderConcreteInfo(nameData.pathTokens, index + 1, folder);
                        folder.AddChild(currInfo);
                    }

                    folder = currInfo as BundleFolderConcreteInfo;
                    if (folder == null)
                    {
                        m_InErrorState = true;
                        LogFolderAndBundleNameConflict(currInfo.m_Name.fullNativeName);
                        break;
                    }
                }
            }
            return(currInfo as BundleFolderConcreteInfo);
        }