Ejemplo n.º 1
0
        internal 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);
        }
Ejemplo n.º 2
0
        internal static BundleInfo FindBundle(BundleNameData name)
        {
            BundleInfo currNode = s_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);
            }
        }
Ejemplo n.º 3
0
        internal static BundleFolderInfo CreateEmptyBundleFolder(BundleFolderConcreteInfo folder = null)
        {
            folder = (folder == null) ? s_RootLevelBundles : folder;
            string         name     = GetUniqueName(folder) + "/dummy";
            BundleNameData nameData = new BundleNameData(folder.m_Name.bundleName, name);

            return(AddFoldersToBundle(s_RootLevelBundles, nameData));
        }
Ejemplo n.º 4
0
        internal 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));
        }
Ejemplo n.º 5
0
        private static BundleInfo AddBundleToModel(string name)
        {
            if (name == null)
            {
                return(null);
            }

            BundleNameData nameData = new BundleNameData(name);

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

            return(currInfo);
        }
Ejemplo n.º 6
0
        internal static BundleInfo CreateEmptyBundle(BundleFolderInfo folder = null, string newName = null)
        {
            if ((folder as BundleVariantFolderInfo) != null)
            {
                return(CreateEmptyVariant(folder as BundleVariantFolderInfo));
            }

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

            nameData = new BundleNameData(folder.m_Name.bundleName, name);
            return(AddBundleToFolder(folder, nameData));
        }
Ejemplo n.º 7
0
        private static BundleInfo AddBundleToFolder(BundleFolderInfo root, BundleNameData nameData)
        {
            BundleInfo currInfo = root.GetChild(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.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)
                    {
                        s_InErrorState = true;
                        LogFolderAndBundleNameConflict(nameData.fullNativeName);
                    }
                }
            }
            return(currInfo);
        }
Ejemplo n.º 8
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)
                    {
                        s_InErrorState = true;
                        LogFolderAndBundleNameConflict(currInfo.m_Name.fullNativeName);
                        break;
                    }
                }
            }
            return(currInfo as BundleFolderConcreteInfo);
        }
Ejemplo n.º 9
0
        internal static BundleFolderInfo CreateNamedBundleFolder(BundleFolderConcreteInfo folder)
        {
            BundleNameData nameData = new BundleNameData(folder.m_Name.bundleName, "dummy");

            return(AddFoldersToBundle(s_RootLevelBundles, nameData));
        }
Ejemplo n.º 10
0
 internal 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);
 }
Ejemplo n.º 11
0
 internal BundleInfo(string name, BundleFolderInfo parent)
 {
     m_Name   = new BundleNameData(name);
     m_Parent = parent;
 }