예제 #1
0
        internal static void Open()
        {
            win = GetWindow <EasyAssetBundleAssetListWindow>(true);
            win.titleContent.text = "AssetBundleList";

            Initialize();
            Undo.undoRedoPerformed -= Initialize;
            Undo.undoRedoPerformed += Initialize;
        }
        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();
        }