Beispiel #1
0
        private void TreeView()
        {
            var data   = EasyAssetBundleWindow.win.SelectedData;
            var config = data.Config;

            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            treeView.searchString = SearchText;
            treeView.OnGUI(GUILayoutUtility.GetLastRect());
            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
                {
                    if (GUILayout.Button("Check Selection", EditorStyles.toolbarButton, GUILayout.Width(90)))
                    {
                        UndoHelper.BuilderDataUndo("Check Selection");
                        for (int i = 0; i < treeView.state.selectedIDs.Count; i++)
                        {
                            data.VersionAssets[treeView.state.selectedIDs[i]].IsBuild = true;
                        }
                    }
                    if (GUILayout.Button("UnCheck All", EditorStyles.toolbarButton, GUILayout.Width(75)))
                    {
                        UndoHelper.BuilderDataUndo("Uncheck all AssetList");
                        for (int i = 0; i < data.VersionAssets.Count; i++)
                        {
                            data.VersionAssets[i].IsBuild = false;
                        }
                    }
                    GUILayout.FlexibleSpace();
                    Undo.IncrementCurrentGroup();
                    UndoHelper.AssetListWindowUndo("Edit AssetList name");
                    SaveAssetBundleListName = EditorGUILayout.TextField(SaveAssetBundleListName, EditorStyles.toolbarTextField, GUILayout.Width(150));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Convert", new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(25) }))
                    {
                        var convertPath = string.IsNullOrEmpty(config.AssetBundleListConfig.AssetBundleListConvertPath) ? Application.dataPath : config.AssetBundleListConfig.AssetBundleListConvertPath;
                        var savePath    = EditorUtility.SaveFilePanel("Convert AssetBundleList", convertPath, "ConvertFile", config.AssetBundleListConfig.AssetBundleListConvertExtension);
                        if (!string.IsNullOrEmpty(savePath))
                        {
                            savePath = FileHelper.SystemPathToAssetPath(savePath);
                            data.ConvertAssetBundleList(data.VersionAssets, savePath);
                        }
                    }
                    GUI.backgroundColor = Color.yellow;
                    if (GUILayout.Button("Save", new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(25) }))
                    {
                        data.CurrentAssetBundleListName = SaveAssetBundleListName;
                        var processor = new EasyAssetBundleBuildProcessor(data, BuildProgress.SaveVersionFile, BuildProgress.SaveVersionFile);
                        processor.OnBuildProcessEnd += () => {
                            data.LoadNewestAssetBundleList();
                            data.ApplyVersionListConfig();
                        };
                        processor.Build("AssetBundleList Save Complete");
                    }
                    GUI.backgroundColor = Color.white;
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
        private void RightArea()
        {
            if (!WindowHelper.BuilderDataExists)
            {
                EditorGUILayout.BeginVertical();
                EditorGUILayout.HelpBox("No BuilderData.", MessageType.Warning);
                EditorGUILayout.EndVertical();
                return;
            }

            EditorGUILayout.BeginVertical(GUIHelper.Styles.NoSpaceBox);
            {
                if (treeView != null)
                {
                    EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                    {
                        GUILayout.FlexibleSpace();
                        if (IsUseAssetBundleList)
                        {
                            if (GUILayout.Button("Open AssetList", EditorStyles.toolbarButton, GUILayout.Width(90)))
                            {
                                UndoHelper.BuilderDataUndo("Apply Config");
                                SelectedData.LoadNewestAssetBundleList();
                                SelectedData.ApplyVersionListConfig();
                                EasyAssetBundleAssetListWindow.Open();
                            }
                            GUILayout.Space(5);
                        }
                        var buildAssetMenu = EditorGUILayout.Popup(0, WindowHelper.MENU_BUILDERASSETMENU, EditorStyles.toolbarPopup, GUILayout.Width(90));
                        switch (buildAssetMenu)
                        {
                        case 2:
                            UndoHelper.BuilderDataUndo("Select files");
                            for (int i = 0; i < SelectedData.BuildAssets.Count; i++)
                            {
                                SelectedData.BuildAssets[i].IsBuild = SelectedData.BuildAssets[i].IsAsset;
                            }
                            break;

                        case 3:
                            UndoHelper.BuilderDataUndo("Select DifferentUnityVersion");
                            if (!IsUseAssetBundleList)
                            {
                                return;
                            }
                            for (int i = 0; i < SelectedData.BuildAssets.Count; i++)
                            {
                                SelectedData.BuildAssets[i].IsBuild = !SelectedData.BuildAssets[i].OldUnityVersion.Equals(Application.unityVersion);
                            }
                            break;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndVertical();

                    treeView.OnGUI(GUILayoutUtility.GetLastRect());

                    EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                    {
                        if (GUILayout.Button("Check Selection", EditorStyles.toolbarButton, GUILayout.Width(90)))
                        {
                            UndoHelper.BuilderDataUndo("Check Selection");
                            for (int i = 0; i < treeView.state.selectedIDs.Count; i++)
                            {
                                SelectedData.BuildAssets[treeView.state.selectedIDs[i]].IsBuild = true;
                            }
                        }
                        if (GUILayout.Button("Disable All", EditorStyles.toolbarButton, GUILayout.Width(70)))
                        {
                            UndoHelper.BuilderDataUndo("Disable all");
                            for (int i = 0; i < SelectedData.BuildAssets.Count; i++)
                            {
                                SelectedData.BuildAssets[i].IsBuild = false;
                            }
                        }
                        if (GUILayout.Button("Expand All", EditorStyles.toolbarButton, GUILayout.Width(70)))
                        {
                            treeView.ExpandAll();
                        }
                        GUILayout.FlexibleSpace();
                        if (IsUseAssetBundleList)
                        {
                            var listName = EditorGUILayout.TextField(SelectedData.CurrentAssetBundleListName, EditorStyles.toolbarTextField, GUILayout.Width(200));
                            if (listName != SelectedData.CurrentAssetBundleListName)
                            {
                                UndoHelper.BuilderDataUndo("Edit AssetList name");
                                SelectedData.CurrentAssetBundleListName = listName;
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandWidth(true));
                        {
                            GUILayout.Label(string.Format("Build: {0}", SelectedData.BuildAssets.Count(a => a.IsBuild)));
                            GUILayout.Label(string.Format("InValid: {0}", SelectedData.BuildAssets.Count(a => !a.IsAvailable)));
                        }
                        EditorGUILayout.EndVertical();

                        GUI.backgroundColor = Color.green;
                        if (GUILayout.Button("Build", new GUILayoutOption[] { GUILayout.Width(200), GUILayout.ExpandHeight(true) }))
                        {
                            var processor = new EasyAssetBundleBuildProcessor(SelectedData);
                            processor.OnBuildProcessEnd += () => {
                                if (IsUseAssetBundleList)
                                {
                                    SelectedData.ApplyConfig();
                                    SelectedData.LoadNewestAssetBundleList();
                                    SelectedData.ApplyVersionListConfig();
                                    TreeViewInitialize();
                                    EasyAssetBundleAssetListWindow.Open();
                                }
                            };
                            processor.Build();
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.HelpBox("set build config.", MessageType.Warning);
                    GUILayout.FlexibleSpace();
                }
            }
            EditorGUILayout.EndVertical();
        }