예제 #1
0
    void OnGUI()
    {
        if (m_DragHandler == null)
        {
            // Setup GUI handler
            m_DragHandler = new GUIDragHandler();
            m_DragHandler.dragIdentifier = "BundleTreeView";
            m_DragHandler.AddRecieveIdentifier(m_DragHandler.dragIdentifier);
            m_DragHandler.canRecieveCallBack = OnCanRecieve;
            m_DragHandler.reciveDragCallBack = OnRecieve;
        }

        if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.DragUpdated || !HasFocuse())
        {
            // Any mouse down msg or lose focuse will cancle the edit waiting process
            m_EditWaitStartTime = -1;
            m_EditWaitBundle    = "";
        }

        Rect curWindowRect = EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("OL Box"));

        {
            // Update rect info
            if (Event.current.type != EventType.Layout)
            {
                m_rect = curWindowRect;
            }

            // Toobar
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            {
                // Create drop down
                Rect createBtnRect = GUILayoutUtility.GetRect(new GUIContent("Create"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(createBtnRect, "Create", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    if (m_Selections.Count <= 1)
                    {
                        menu.AddItem(new GUIContent("Scene Bundle"), false, CreateSceneBundle);
                        menu.AddItem(new GUIContent("Asset Bundle"), false, CreateAssetBundle);
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Scene Bundle"), false, null);
                        menu.AddItem(new GUIContent("Asset Bundle"), false, null);
                    }
                    menu.DropDown(createBtnRect);
                }

                // Build button
                Rect buildBtnRect = GUILayoutUtility.GetRect(new GUIContent("Build"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(buildBtnRect, "Build", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Build Selection"), false, BuildSelection);
                    menu.AddItem(new GUIContent("Build Selection and Upload"), false, BuildSelectionAndUpload);
                    menu.AddItem(new GUIContent("Upload Selection"), false, UploadBuiltSelection);
                    menu.AddItem(new GUIContent("Rebuild Selection"), false, RebuildSelection);
                    menu.AddItem(new GUIContent("Build All"), false, BuildAll);
                    menu.AddItem(new GUIContent("Rebuild All"), false, RebuildAll);
                    menu.AddItem(new GUIContent("Clear"), false, ClearOutputs);
                    menu.DropDown(buildBtnRect);
                }

                Rect checkBtnRect = GUILayoutUtility.GetRect(new GUIContent("Check"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(checkBtnRect, "Check", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Check asset sort valid"), false, CheckAssetSortValid);
                    menu.DropDown(buildBtnRect);
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
                {
                    BMSettingsEditor.Show();
                }
            }
            EditorGUILayout.EndHorizontal();

            // Tree view
            m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos);
            {
                m_CurrentShowingBundles.Clear();

                foreach (BundleData rootBundle in BundleManager.Roots)
                {
                    if (!GUI_TreeItem(0, rootBundle.name))
                    {
                        Repaint();
                        break;
                    }
                }

                m_LastTimeShowingBundles.Clear();
                m_LastTimeShowingBundles.AddRange(m_CurrentShowingBundles);

                if (m_CurrentEditing == "")
                {
                    ArrowKeyProcess();
                    HotkeyProcess();
                }

                // Empty space for root selection
                Rect spaceRect = EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("Space"));
                GUILayout.Space(m_ItemHeight);
                EditorGUILayout.EndVertical();
                RootSpaceProcess(spaceRect);
            } EditorGUILayout.EndScrollView();

            Rect scrollViewRect = GUILayoutUtility.GetLastRect();
            if (scrollViewRect.height != 1)
            {
                UpdateScrollBarBySelection(scrollViewRect.height);
            }
        } EditorGUILayout.EndVertical();
    }
예제 #2
0
    void OnGUI()
    {
        System.Action _Task = null;
        if (m_DragHandler == null)
        {
            // Setup GUI handler
            m_DragHandler = new GUIDragHandler();
            m_DragHandler.dragIdentifier = "BundleTreeView";
            m_DragHandler.AddRecieveIdentifier(m_DragHandler.dragIdentifier);
            m_DragHandler.canRecieveCallBack = OnCanRecieve;
            m_DragHandler.reciveDragCallBack = OnRecieve;
        }
        if (m_InfoIcon == null)
        {
            m_InfoIcon = EditorGUIUtility.IconContent("console.infoicon.sml");
            m_WarnIcon = EditorGUIUtility.IconContent("console.warnicon.sml");
        }

        if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.DragUpdated || !HasFocuse())
        {
            // Any mouse down msg or lose focuse will cancle the edit waiting process
            m_EditWaitStartTime = -1;
            m_EditWaitBundle    = "";
        }

        Rect curWindowRect = EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("OL Box"));

        {
            // Update rect info
            if (Event.current.type != EventType.Layout)
            {
                m_rect = curWindowRect;
            }

            // Toobar
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            {
                // Create drop down
                Rect createBtnRect = GUILayoutUtility.GetRect(new GUIContent("Create"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(createBtnRect, "Create", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    if (m_Selections.Count <= 1)
                    {
                        menu.AddItem(new GUIContent("Scene Bundle"), false, CreateSceneBundle);
                        menu.AddItem(new GUIContent("Asset Bundle"), false, CreateAssetBundle);
                        menu.AddItem(new GUIContent("Text Bundle"), false, CreateTextBundle);
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Scene Bundle"), false, null);
                        menu.AddItem(new GUIContent("Asset Bundle"), false, null);
                        menu.AddItem(new GUIContent("Text Bundle"), false, null);
                    }
                    if (m_Selections.Count == 1)
                    {
                        menu.AddItem(new GUIContent("Quick Create"), false, QuickCreateAssetBundle);
                    }
                    if (m_Selections.Count == 1 && m_Selections[0].StartsWith("Character/model_"))
                    {
                        menu.AddItem(new GUIContent("Create Combat Bundle For This Character"), false, _CreateCombatBundleForCharacter);
                    }
                    menu.DropDown(createBtnRect);
                }
                if (GUILayout.Button("Build Sel", EditorStyles.toolbarButton))
                {
                    _Task = BuildSelection;
                }
                if (GUILayout.Button("Build All", EditorStyles.toolbarButton))
                {
                    _Task = BuildHelper.BuildAll;
                }
                EditorGUILayout.Space();
                Rect scanRect = GUILayoutUtility.GetRect(new GUIContent("Scan"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(scanRect, "Scan", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Update Dependencies"), false, UpdateDependenciesForAllBundles);
                    menu.AddItem(new GUIContent("Update Bundle Changes"), false, ScanChangesForAllBundles);
                    menu.DropDown(scanRect);
                }
                // Build button
                Rect buildBtnRect = GUILayoutUtility.GetRect(new GUIContent("Build"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(buildBtnRect, "Build", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Build Selection"), false, BuildSelection);
                    menu.AddItem(new GUIContent("Rebuild Selection"), false, RebuildSelection);
                    menu.AddItem(new GUIContent("Build Selection(Don't Refresh)"), false, DirectBuildSelection);
                    menu.AddItem(new GUIContent("Build All"), false, BuildHelper.BuildAll);
                    menu.AddItem(new GUIContent("Rebuild All"), false, BuildHelper.RebuildAll);
                    menu.AddItem(new GUIContent("Build All (Don't Refresh)"), false, BuildHelper.DirectBuildAll);
                    menu.AddItem(new GUIContent("Clear"), false, ClearOutputs);
                    menu.AddSeparator("");
                    menu.AddItem(new GUIContent("Copy To DownloadPath"), false, CopyToDownloadPath);
                    menu.DropDown(buildBtnRect);
                }

                GUILayout.FlexibleSpace();

                GUILayout.Label(m_Selections.Count + " Selected");
                if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
                {
                    BMSettingsEditor.Show();
                }
            }
            EditorGUILayout.EndHorizontal();

            // Tree view
            m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos);
            {
                m_CurrentShowingBundles.Clear();

                foreach (BundleData rootBundle in BundleManager.Roots)
                {
                    if (!GUI_TreeItem(0, rootBundle.name))
                    {
                        Repaint();
                        break;
                    }
                }

                m_LastTimeShowingBundles.Clear();
                m_LastTimeShowingBundles.AddRange(m_CurrentShowingBundles);

                if (m_CurrentEditing == "")
                {
                    ArrowKeyProcess();
                    HotkeyProcess();
                }

                // Empty space for root selection
                Rect spaceRect = EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("Space"));
                GUILayout.Space(m_ItemHeight);
                EditorGUILayout.EndVertical();
                RootSpaceProcess(spaceRect);
            } EditorGUILayout.EndScrollView();

            Rect scrollViewRect = GUILayoutUtility.GetLastRect();
            if (scrollViewRect.height != 1)
            {
                UpdateScrollBarBySelection(scrollViewRect.height);
            }
        } EditorGUILayout.EndVertical();
        if (_Task != null)
        {
            _Task();
        }
    }