Пример #1
0
    void OnGUI()
    {
        if (mDragHandler == null)
        {
            mDragHandler = new GUIDragHandler();
            mDragHandler.dragIdentifier = "ItemPriorityEditor";
            mDragHandler.AddRecieveIdentifier(mDragHandler.dragIdentifier);
            mDragHandler.canRecieveCallBack = OnCanRecieve;
            mDragHandler.reciveDragCallBack = OnRecieve;
        }

        EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("OL Box"));
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            {
                Rect loadBtnRect = GUILayoutUtility.GetRect(new GUIContent("Load"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(loadBtnRect, "Load", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Load Bundle Ship Info File"), false, LoadBundleShipInfoFile);
                    menu.AddItem(new GUIContent("Save Bundle Ship Info File"), false, SaveBundleShipInfoFile);
                    menu.AddItem(new GUIContent("Sort By Tree And Priority"), false, SortByTreeAndPriority);
                    menu.DropDown(loadBtnRect);
                }
            }
            EditorGUILayout.EndHorizontal();

            if (mCurrentEditItems != null)
            {
                mScrollPosUnBlock = EditorGUILayout.BeginScrollView(mScrollPosUnBlock);
                {
                    if (mCurrentEditItemsChanged)
                    {
                        renderList.Clear();
                        renderList.AddRange(mCurrentEditItems);
                        mCurrentEditItemsChanged = false;
                    }

                    foreach (GM.BundleInfo itemDesc in renderList)
                    {
                        GUIDrawItemDesc(itemDesc);
                    }
                }
                EditorGUILayout.EndScrollView();
            }
        }
        EditorGUILayout.EndVertical();
    }
Пример #2
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.GetBuildinStyle("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("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);
                }

                GUILayout.FlexibleSpace();

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

            // Tree view
            m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos);
            {
                m_CurrentShowingBundles.Clear();
                string path = "-1";
                bool onT = false;
                string pathKey = "";
                foreach (BundleData rootBundle in BundleManager.Roots)
                {
                    if (rootBundle.path != path)
                    {
                        if (onT)
                        {
                            EditorGUILayout.EndToggleGroup();
                        }
                        path = rootBundle.path;
                        pathKey = path == "" ? "nopath" : path;
                        SetPathFold(pathKey, EditorGUILayout.BeginToggleGroup("[" + pathKey + "]", IsPathFold(pathKey)));
                        onT = true;
                    }
                    if (IsPathFold(pathKey))
                        if (!GUI_TreeItem(0, rootBundle.name))
                        {
                            Repaint();
                            break;
                        }
                }
                if (onT)
                {
                    EditorGUILayout.EndToggleGroup();
                }

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

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

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

            } EditorGUILayout.EndScrollView();

            Rect scrollViewRect = GUILayoutUtility.GetLastRect();
            if (scrollViewRect.height != 1)
                UpdateScrollBarBySelection(scrollViewRect.height);

        } EditorGUILayout.EndVertical();
    }
Пример #3
0
    void OnRecieve(GUIDragHandler.DragDatas recieverData, GUIDragHandler.DragDatas dragData)
    {
        if (dragData.customDragData == null && dragData.dragPaths.Length != 0)
        {
            foreach (string dragPath in dragData.dragPaths)
            {
                if (dragPath == null)
                    continue;

                if (BundleManager.CanAddPathToBundle(dragPath, (string)recieverData.customDragData))
                    BundleManager.AddPathToBundle(dragPath, (string)recieverData.customDragData);
            }
        }
        else
            BundleManager.SetParent((string)dragData.customDragData, (string)recieverData.customDragData);
    }
Пример #4
0
    bool OnCanRecieve(GUIDragHandler.DragDatas recieverData, GUIDragHandler.DragDatas dragData)
    {
        if (dragData.customDragData == null && dragData.dragPaths.Length != 0)
        {
            foreach (string dragPath in dragData.dragPaths)
            {
                if (dragPath == null)
                    continue;

                if (BundleManager.CanAddPathToBundle(dragPath, (string)recieverData.customDragData))
                    return true;
            }

            return false;
        }
        else
        {
            return BundleManager.CanBundleParentTo((string)dragData.customDragData, (string)recieverData.customDragData);
        }
    }
Пример #5
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();
    }
Пример #6
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();
        }
    }