Пример #1
0
    /**
     * Remove the bundle by the given name.
     * @Return Return false if no such bundle.
     */
    static public bool RemoveBundle(string name)
    {
        var bundleDict     = getInstance().bundleDict;
        var bundlelist     = BMDataAccessor.Bundles;
        var dependRefDict  = getInstance().dependRefDict;
        var includeRefDict = getInstance().includeRefDict;
        var statesDict     = getInstance().statesDict;

        if (!bundleDict.ContainsKey(name))
        {
            return(false);
        }

        BundleData bundle = bundleDict[name];

        bundlelist.Remove(bundle);
        bundleDict.Remove(name);

        var buildStatesDict = getInstance().statesDict;

        BMDataAccessor.BuildStates.Remove(buildStatesDict[name]);
        buildStatesDict.Remove(name);

        // Remove parent ref
        if (bundle.parent != "" && bundleDict.ContainsKey(bundle.parent))
        {
            bundleDict[bundle.parent].GetChildren().Remove(name);
        }

        // Remove include ref
        foreach (string guid in bundle.includeGUIDs)
        {
            if (includeRefDict.ContainsKey(guid))
            {
                includeRefDict[guid].Remove(bundle);
            }
        }

        // Remove depend asssets ref
        foreach (string guid in bundle.GetExtraData().dependGUIDs)
        {
            dependRefDict[guid].Remove(bundle);
        }

        // Delete children recursively
        foreach (string childName in bundle.GetChildren())
        {
            RemoveBundle(childName);
        }

        //Remove buildState
        if (statesDict.ContainsKey(name))
        {
            statesDict.Remove(name);
        }

        return(true);
    }
Пример #2
0
    public static void MarkTreeChanged(BundleData bundle)
    {
        var state = GetBuildStateOfBundle(bundle.name);

        state.changed = true;
        foreach (var childName in bundle.GetChildren())
        {
            MarkTreeChanged(GetBundleData(childName));
        }
    }
Пример #3
0
    bool GUI_DrawChildren(string bundleName, int indent)
    {
        BundleData bundleData = BundleManager.GetBundleData(bundleName);

        if (bundleData.GetChildren().Count == 0 || IsFold(bundleName))
        {
            return(true);
        }

        for (int i = 0; i < bundleData.GetChildren().Count; ++i)
        {
            if (!GUI_TreeItem(indent + 1, bundleData.GetChildren()[i]))
            {
                return(false);
            }
        }

        return(true);
    }
Пример #4
0
    internal static bool BuildBundleTree(BundleData bundle, List <string> requiredBuildList)
    {
        BuildPipeline.PushAssetDependencies();

        bool succ = BuildSingleBundle(bundle);

        if (!succ)
        {
            Debug.LogError(bundle.name + " build failed.");
            //为了实现能够跳过build错误的bundle继续进行打包而注释
            //BuildPipeline.PopAssetDependencies();
            //return false;
        }
        else
        {
            var buildState = BundleManager.GetBuildStateOfBundle(bundle.name);
            Debug.Log(bundle.name + " build succeed.");
        }
        if (succ)
        {
            foreach (string childName in bundle.GetChildren())
            {
                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;
                    }
                }

                if (isDependingBundle || !BuildConfiger.DeterministicBundle)
                {
                    succ = BuildBundleTree(child, requiredBuildList);
                    if (!succ)
                    {
                        BuildPipeline.PopAssetDependencies();
                        return(false);
                    }
                }
            }
        }
        BuildPipeline.PopAssetDependencies();
        return(true);
    }
Пример #5
0
    /**
     * Set the parent of the bundle.
     * @param parent New parent bundle's name. Set the parent to empty if you want the childe bundle become a root bundle.
     */
    static public void SetParent(string childe, string parent)
    {
        if (!CanBundleParentTo(childe, parent))
        {
            return;
        }

        var bundleDict = getInstance().bundleDict;

        if (!bundleDict.ContainsKey(childe) || (parent != "" && !bundleDict.ContainsKey(parent)))
        {
            return;
        }

        BundleData childeBundle = bundleDict[childe];

        if (bundleDict.ContainsKey(childeBundle.parent))
        {
            bundleDict[childeBundle.parent].GetChildren().Remove(childe);
        }

        string origParent = childeBundle.parent;

        childeBundle.parent = parent;

        if (parent != "")
        {
            BundleData newParentBundle = bundleDict[parent];
            newParentBundle.GetChildren().Add(childe);
            newParentBundle.GetChildren().Sort();
        }

        if (parent == "" || origParent == "")
        {
            BMDataAccessor.Bundles.Remove(childeBundle);
            InsertBundleToBundleList(childeBundle);
        }
        MarkTreeChanged(childeBundle);
        UpdateAllBundlesNeedBuild();
        BMDataAccessor.ShouldSaveBundleData = true;
    }
Пример #6
0
    /**
     * Rename the bundle.
     * @Return Return false if there's no such bundle, or the new name is used.
     */
    static public bool RenameBundle(string origName, string newName)
    {
        if (newName == "" || origName == newName || getInstance().bundleDict.ContainsKey(newName) || !getInstance().bundleDict.ContainsKey(origName))
        {
            return(false);
        }

        BundleData bundle = getInstance().bundleDict[origName];

        bundle.name = newName;

        Dictionary <string, BundleData> bundleDict = getInstance().bundleDict;

        bundleDict.Remove(origName);
        bundleDict.Add(newName, bundle);

        if (bundle.parent != "")
        {
            BundleData parentBundle = bundleDict[bundle.parent];
            parentBundle.GetChildren().Remove(origName);
            parentBundle.GetChildren().Add(newName);
        }

        foreach (string childName in bundle.GetChildren())
        {
            getInstance().bundleDict[childName].parent = newName;
        }

        var buildStatesDic          = getInstance().statesDict;
        BundleBuildState buildState = buildStatesDic[origName];

        buildState.bundleName = newName;
        buildStatesDic.Remove(origName);
        buildStatesDic.Add(newName, buildState);

        BMDataAccessor.SaveBundleData();
        BMDataAccessor.SaveBundleBuildeStates();
        return(true);
    }
Пример #7
0
    Rect GUI_DrawItem(BundleData bundle, int indent)
    {
        var extra = bundle.GetExtraData();
        var state = BundleManager.GetBuildStateOfBundle(bundle.name);

        bool isEditing   = m_CurrentEditing == bundle.name;
        bool isRecieving = m_CurrentRecieving == bundle.name;
        bool isSelected  = m_Selections.Contains(bundle.name);

        GUIStyle currentLableStyle = BMGUIStyles.GetStyle("TreeItemUnSelect");

        if (isRecieving)
        {
            currentLableStyle = BMGUIStyles.GetStyle("receivingLable");
        }
        else if (isSelected && !isEditing)
        {
            currentLableStyle = HasFocuse() ? BMGUIStyles.GetStyle("TreeItemSelectBlue") : BMGUIStyles.GetStyle("TreeItemSelectGray");
        }

        Rect itemRect = EditorGUILayout.BeginHorizontal(currentLableStyle);

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

        Texture2D bundleIcon = null;

        switch (bundle.bundleType)
        {
        case BundleType.Scene:
            bundleIcon = BMGUIStyles.GetIcon("sceneBundleIcon");
            break;

        case BundleType.Text:
            bundleIcon = BMGUIStyles.GetIcon("textBundleIcon");
            break;

        default:
            bundleIcon = BMGUIStyles.GetIcon("assetBundleIcon");
            break;
        }
        GUILayout.Label(bundleIcon, BMGUIStyles.GetStyle("BItemLabelNormal"), GUILayout.ExpandWidth(false));
        //GUILayout.Label(bundle.sceneBundle ? BMGUIStyles.GetIcon("sceneBundleIcon") : BMGUIStyles.GetIcon("assetBundleIcon"), BMGUIStyles.GetStyle("BItemLabelNormal"), GUILayout.ExpandWidth(false));

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

        var r = GUILayoutUtility.GetLastRect();

        r.x      = r.xMax - 20;
        r.height = 20;
        if (state.changed)
        {
            GUI.Label(r, m_WarnIcon);
        }
        else if (extra.needBuild)
        {
            GUI.Label(r, m_InfoIcon);
        }

        EditorGUILayout.EndHorizontal();

        return(itemRect);
    }