private static BMGUIStyles getInstance() { if (instance == null) { // Instancial instance = new BMGUIStyles(); GUIStyleSet styleSet = (GUIStyleSet)AssetDatabase.LoadAssetAtPath("Assets/BundleManager/Editor/customStyles.asset", typeof(GUIStyleSet)); var styles = EditorGUIUtility.isProSkin ? styleSet.styles : styleSet.freeStyles; foreach (GUIStyle style in styles) { if (instance.styleDict.ContainsKey(style.name)) { Debug.LogError("Duplicated GUIStyle " + style.name); } else { instance.styleDict.Add(style.name, style); } } foreach (Texture2D icon in styleSet.icons) { if (instance.iconDict.ContainsKey(icon.name)) { Debug.LogError("Duplicated icon " + icon.name); } else { instance.iconDict.Add(icon.name, icon); } } } return(instance); }
private static BMGUIStyles getInstance() { if(instance == null) { // Instancial instance = new BMGUIStyles(); GUIStyleSet styleSet = (GUIStyleSet)AssetDatabase.LoadAssetAtPath("Assets/BundleManager/customStyles.asset", typeof(GUIStyleSet)); foreach(GUIStyle style in styleSet.styles) { if(instance.styleDict.ContainsKey(style.name)) Debug.LogError("Duplicated GUIStyle " + style.name); else instance.styleDict.Add(style.name, style); } foreach(Texture2D icon in styleSet.icons) { if(instance.iconDict.ContainsKey(icon.name)) Debug.LogError("Duplicated icon " + icon.name); else instance.iconDict.Add(icon.name, icon); } } return instance; }
private static BMGUIStyles getInstance() { if (instance == null) { // Instancial instance = new BMGUIStyles(); GUIStyleSet styleSet = (GUIStyleSet)AssetDatabase.LoadAssetAtPath("Assets/Scripts/Plugin/BundleManager/customStyles.asset", typeof(GUIStyleSet)); foreach (GUIStyle style in styleSet.styles) { if (instance.styleDict.ContainsKey(style.name)) { UnityEngine.Debug.LogError("Duplicated GUIStyle " + style.name); } else { instance.styleDict.Add(style.name, style); } } foreach (Texture2D icon in styleSet.icons) { if (instance.iconDict.ContainsKey(icon.name)) { UnityEngine.Debug.LogError("Duplicated icon " + icon.name); } else { instance.iconDict.Add(icon.name, icon); } } } return(instance); }
static Texture2D GetSharedIconOfInlucde(string assetPath) { var bundleList = BundleManager.GetRelatedBundles(assetPath); if (bundleList != null && bundleList.Count > 0) { foreach (BundleData bundle in bundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(bundle.name, currentBundle.name)) { return(BMGUIStyles.GetIcon("dependedAsset")); } else if (BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("sharedAsset")); } } } bundleList = BundleManager.GetIncludeBundles(assetPath); if (bundleList != null && bundleList.Count > 1) { return(BMGUIStyles.GetIcon("duplicatedInclude")); } return(null); }
static void GUI_Inlcudes() { if (currentBundle.includs.Count > 0) { #if UNITY_4_3 m_FoldoutIncludes = EditorGUILayout.Foldout(m_FoldoutIncludes, "INCLUDE", BMGUIStyles.GetCustomStyle("CFoldout")); #else m_FoldoutIncludes = EditorGUILayout.Foldout(m_FoldoutIncludes, "INCLUDE"); #endif } else { GUILayout.Label("INCLUDE", BMGUIStyles.GetCustomStyle("UnfoldableTitle")); } if (!m_FoldoutIncludes) { return; } EditorGUILayout.BeginVertical(); { foreach (var assetPath in currentBundle.includs) { bool isCurrentPathSelect = m_CurSelectAsset == assetPath && !m_IsMetaListSelect; AssetItemState itemState = GUI_AssetItem(assetPath, isCurrentPathSelect, GetSharedIconOfInlucde(assetPath)); if (itemState != AssetItemState.None) { if (!isCurrentPathSelect) { m_IsMetaListSelect = false; m_CurSelectAsset = assetPath; } else if (itemState != AssetItemState.RClicked) // Only left click can disable selection { if (EditorApplication.timeSinceStartup - m_LastClickTime < 2f) { // Double clicked EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object))); } else { m_CurSelectAsset = ""; } } m_LastClickTime = EditorApplication.timeSinceStartup; Refresh(); // Right click if (itemState == AssetItemState.RClicked) { GenericMenu rightClickMenu = new GenericMenu(); rightClickMenu.AddItem(new GUIContent("Delete"), false, GUI_DeleteMenuCallback); rightClickMenu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0)); } } } } EditorGUILayout.EndVertical(); }
void GUIDrawItemDesc(GM.BundleInfo itemDesc) { bool isReceiving = mCurrentRecieving == itemDesc; bool isSelecting = mSelections.Contains(itemDesc); GUIStyle currentLabelStyle = BMGUIStyles.GetStyle("TreeItemUnSelect"); if (isReceiving) { currentLabelStyle = BMGUIStyles.GetStyle("receivingLable"); } else if (isSelecting) { currentLabelStyle = HasFocus() ? BMGUIStyles.GetStyle("TreeItemSelectBlue") : BMGUIStyles.GetStyle("TreeItemSelectGray"); } Rect itemRect = EditorGUILayout.BeginHorizontal(currentLabelStyle); GUILayout.Label(BMGUIStyles.GetIcon("assetBundleIcon"), BMGUIStyles.GetStyle("BItemLabelNormal"), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent(itemDesc.BundleName), isSelecting ? BMGUIStyles.GetStyle("BItemLabelActive") : BMGUIStyles.GetStyle("BItemLabelNormal"), GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); if (DragProcess(itemRect, itemDesc)) { return; } SelectProcess(itemRect, itemDesc); }
public static void DrawInspector() { if (currentBundle == null) { GUILayout.FlexibleSpace(); GUILayout.Label("Select bundle to check its content."); GUILayout.FlexibleSpace(); return; } m_ScrollViewPosition = EditorGUILayout.BeginScrollView(m_ScrollViewPosition); { // Bundle type and version BundleBuildState buildStates = BundleManager.GetBuildStateOfBundle(currentBundle.name); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(currentBundle.sceneBundle ? "Scene bundle" : "Asset bundle", BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); GUILayout.Label("Version " + buildStates.version, BMGUIStyles.GetStyle("BoldLabel")); } EditorGUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { string sizeStr = "Build Size " + (buildStates.size == -1 ? "Unkown" : Mathf.CeilToInt(buildStates.size / 1024f) + " KB"); GUILayout.Label(sizeStr, BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); GUILayout.Label("Priority", EditorStyles.boldLabel); int opriority = currentBundle.priority; currentBundle.priority = EditorGUILayout.Popup(currentBundle.priority, new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, GUILayout.MaxWidth(40)); if (opriority != currentBundle.priority) { BMDataAccessor.SaveBundleData(); } } GUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("Wizard Box")); { GUI_Inlcudes(); GUI_DependencyList(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh") && currentBundle != null) { BundleManager.RefreshBundleDependencies(currentBundle); BMDataAccessor.SaveBundleData(); } } GUILayout.EndHorizontal(); }
static Texture2D GetSharedIconOfDepend(string guid) { var bundleList = BundleManager.GetIncludeBundles(guid); if (bundleList != null && bundleList.Count > 0) { foreach (BundleData bundle in bundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("sharedAsset")); } } } bundleList = BundleManager.GetExIncludeBundles(guid); if (bundleList != null && bundleList.Count > 0) { foreach (BundleData bundle in bundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("sharedAsset")); } } } bundleList = BundleManager.GetRelatedBundles(guid); if (bundleList != null && bundleList.Count > 1) { foreach (BundleData bundle in bundleList) { if (bundle.name == currentBundle.name) { continue; } if (!BundleManager.IsBundleDependOn(bundle.name, currentBundle.name) && !BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("duplicatedDepend")); } } } return(null); }
static void GUI_DependencyList() { if (currentBundle.dependGUIDs.Count > 0) { #if !(UNITY_4_2 || UNITY_4_1 || UNITY_4_0) m_FoldoutMetaFiles = EditorGUILayout.Foldout(m_FoldoutMetaFiles, "DEPEND", BMGUIStyles.GetStyle("CFoldout")); #else m_FoldoutMetaFiles = EditorGUILayout.Foldout(m_FoldoutMetaFiles, "DEPEND"); #endif } else { GUILayout.Label("DEPEND", BMGUIStyles.GetStyle("UnfoldableTitle")); return; } if (m_FoldoutMetaFiles) { EditorGUILayout.BeginVertical(); { foreach (string guid in currentBundle.dependGUIDs) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); bool isCurrentPathSelect = m_CurSelectAsset == guid && m_IsMetaListSelect; if (GUI_AssetItem(assetPath, isCurrentPathSelect, GetSharedIconOfDepend(guid)) != AssetItemState.None) { if (!isCurrentPathSelect) { m_IsMetaListSelect = true; m_CurSelectAsset = guid; } else { if (EditorApplication.timeSinceStartup - m_LastClickTime < 2f) { // Double clicked EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object))); } else { m_CurSelectAsset = ""; } } m_LastClickTime = EditorApplication.timeSinceStartup; Refresh(); } } } EditorGUILayout.EndVertical(); } }
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(); }
static GUIStyle GetLabelStyle(bool selected, bool exist) { if (!exist) { return(BMGUIStyles.GetStyle("CAssetLabelRed")); } if (selected) { return(BMGUIStyles.GetStyle("CAssetLabelActive")); } else { return(BMGUIStyles.GetStyle("CAssetLabelNormal")); } }
Rect GUI_DrawItem(BundleData bundle, int indent) { 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.children.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); } 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 = EditorGUILayout.TextField(m_EditString, BMGUIStyles.GetStyle("TreeEditField")); } EditorGUILayout.EndHorizontal(); return(itemRect); }
static GUIStyle GetItemStyle(bool selected, bool focused) { if (!selected) { return(BMGUIStyles.GetStyle("TreeItemUnSelect")); } else { if (focused) { return(BMGUIStyles.GetStyle("TreeItemSelectBlue")); } else { return(BMGUIStyles.GetStyle("TreeItemSelectGray")); } } }
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(); } }
static Texture2D GetSharedIconOfInlucde(string guid) { var includeBundleList = BundleManager.GetIncludeBundles(guid); if (includeBundleList != null && includeBundleList.Count > 1) { foreach (BundleData bundle in includeBundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("sharedAsset")); } else if (!BundleManager.IsBundleDependOn(bundle.name, currentBundle.name)) { return(BMGUIStyles.GetIcon("duplicatedInclude")); } } } var exIncludeBundleList = BundleManager.GetExIncludeBundles(guid); if (exIncludeBundleList != null && exIncludeBundleList.Count > 1) { foreach (BundleData bundle in exIncludeBundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(currentBundle.name, bundle.name)) { return(BMGUIStyles.GetIcon("sharedAsset")); } else if (!BundleManager.IsBundleDependOn(bundle.name, currentBundle.name)) { return(BMGUIStyles.GetIcon("duplicatedInclude")); } } } var dependBundleList = BundleManager.GetRelatedBundles(guid); if (dependBundleList != null && dependBundleList.Count > 0) { foreach (BundleData bundle in dependBundleList) { if (bundle.name == currentBundle.name) { continue; } if (BundleManager.IsBundleDependOn(bundle.name, currentBundle.name)) { return(BMGUIStyles.GetIcon("dependedAsset")); } } } return(null); }
public void OnGUI() { Color Backup = GUI.color; if (Setting != null) { List <string> Platforms = new List <string>(); Platforms.AddRange(new string[] { "Android", "Standalones", "IOS" }); List <string> BundleNames = new List <string>(); foreach (var OneOf in Setting.ListOfBundles) { BundleNames.Add(OneOf.Name); } if (tipString.Count == 0) { tipString.Add("Platform: 当前支持的平台"); tipString.Add("Game(Common): Game表明当前配置为游戏bundle配置, Common表明是通用bundle配置"); tipString.Add("Amount: 当前配置含有的bundle数量"); tipString.Add("是否拷贝:是否需要拷贝到StreamingAsset目录"); } GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { GUI.color = Color.cyan; foreach (string str in tipString) { GUI.color = Color.white; GUILayout.Label(str, BMGUIStyles.GetStyle("BoldLabel")); //GUILayout.Space(2); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUI.color = Color.white; GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { //platform GUI.color = Color.white; GUILayout.Label("Platform:", BMGUIStyles.GetStyle("BoldLabel")); GUI.color = Color.cyan; SelPlatform = EditorGUILayout.Popup(SelPlatform, Platforms.ToArray(), GUILayout.MaxWidth(80)); GUILayout.FlexibleSpace(); //cook for GUI.color = Color.white; GUILayout.Label("Game(Common):", BMGUIStyles.GetStyle("BoldLabel")); GUI.color = Color.cyan; int section = EditorGUILayout.Popup(focusGame, gameNames.ToArray(), GUILayout.MaxWidth(80)); if (section != focusGame) { focusGame = section; UpdateFocusGame(focusGame); } GUILayout.FlexibleSpace(); //bundle amount GUI.color = Color.white; GUILayout.Label("Amount:", BMGUIStyles.GetStyle("BoldLabel")); GUI.color = Color.cyan; GUILayout.Label("" + Setting.ListOfBundles.Count + " 个", BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); if ((EGameBundle)focusGame != EGameBundle.EGB_ALL) { GUI.color = Color.white; GUILayout.Label("是否拷贝:", BMGUIStyles.GetStyle("BoldLabel")); GUI.color = Color.cyan; section = Setting.bToStreamingAsset == true ? 1 : 0; int result = EditorGUILayout.Popup(section, new string[] { "false", "true" }, new GUILayoutOption[] { GUILayout.MaxWidth(100) }); bool bCopy = result == 0 ? false : true; if (bCopy != Setting.bToStreamingAsset) { foreach (var obj in Setting.ListOfBundles) { obj.bCopy = bCopy; } Setting.bToStreamingAsset = bCopy; } GUI.color = Color.white; } } GUILayout.EndHorizontal(); } GUILayout.Space(10); GUI.color = Color.white; ScrollPos = GUILayout.BeginScrollView(ScrollPos, new GUILayoutOption[] { GUILayout.ExpandHeight(true) }); { GUILayout.MinHeight(600); GUILayout.BeginVertical(BMGUIStyles.GetStyle("Wizard Box")); { for (int Index = 0; Index < Setting.ListOfBundles.Count; ++Index) { BundleInfo.Element OneOf = Setting.ListOfBundles[Index]; if (SelBundle.Equals(OneOf.GetHashCode())) { GUI.color = Color.yellow; } else { GUI.color = new Color(2, 2, 2, 1); } GUILayout.BeginVertical("box"); { GUILayout.BeginHorizontal(); GUILayout.Label("名 称 : "); OneOf.Name = GUILayout.TextArea(OneOf.Name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("路 径 : "); GUILayout.FlexibleSpace(); GUI.color = Color.yellow; GUILayout.Label(OneOf.Path); GUI.color = Color.white; if (GUILayout.Button(BMGUIStyles.GetIcon("assetBundleIcon"), new GUILayoutOption[] { GUILayout.MaxWidth(16), GUILayout.MaxHeight(16) })) { if (Selection.activeObject == null) { EditorUtility.DisplayDialog("提示", "请在Project视图中选择路径!", "OK"); } else { OneOf.Path = AssetDatabase.GetAssetPath(Selection.activeObject).Replace("\\", "/"); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("模 式 : "); OneOf.Mode = (BundleInfo.BundleMode)EditorGUILayout.Popup((int)OneOf.Mode, new string[] { "Separate By SubFiles", "Separate By SubFolders", "All In One Package", "Single File", "Scene Bundle" }, new GUILayoutOption[] { GUILayout.MaxWidth(140) }); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("是否加密 :"); int section = 0; if (OneOf.bEncrypt) { section = 1; } int result = EditorGUILayout.Popup(section, new string[] { "false", "true" }, new GUILayoutOption[] { GUILayout.MaxWidth(140) }); OneOf.bEncrypt = result == 1; GUILayout.EndHorizontal(); } GUILayout.EndVertical(); bool IsRClicked = Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition); if (IsRClicked) { #if UNITY_EDITOR_OSX if ((Event.current.button == 0 && Event.current.control == true) || Event.current.button == 1) { SelBundle = OneOf.GetHashCode(); } #else if (Event.current.button == 1) { SelBundle = OneOf.GetHashCode(); } #endif Repaint(); } } } GUILayout.EndVertical(); } GUILayout.EndScrollView(); } GUILayout.Space(5); GUI.color = Color.green; GUILayout.BeginHorizontal(); { if (GUILayout.Button("保存配置")) { SaveBundleCondfig(); } if (GUILayout.Button("新建")) { Create(); } if (GUILayout.Button("删除")) { Delete(); } if (GUILayout.Button("打包")) { Publish(); } // if (GUILayout.Button("快速打包")) DoMakeBundle(BuildOutPath_, BuildTarget.Android); //if (GUILayout.Button("复制")) CopyResult(); //if (GUILayout.Button("资源复制到res")) CopyRes(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUI.color = Backup; }
private void OnGUI() { if (_list.Count > 0) { GUILayout.Space(5); ScrollPos = GUILayout.BeginScrollView(ScrollPos, new GUILayoutOption[] { GUILayout.ExpandHeight(true) }); { GUILayout.BeginVertical(BMGUIStyles.GetStyle("Wizard Box")); { for (int Index = 0; Index < _list.Count; ++Index) { FGameMacroListItem OneOf = _list[Index]; GUILayout.BeginVertical("box"); { if (OneOf.title == USE_WECHAT) { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("The third sdk setting"); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label(OneOf.title); int section = 0; int result = 0; if (OneOf.macro != GAME_TYPE) { if (OneOf.value) { section = 1; } result = EditorGUILayout.Popup(section, new string[] { "false", "true" }, new GUILayoutOption[] { GUILayout.MaxWidth(140) }); bool bChanged = OneOf.value != (result == 1); OneOf.value = result == 1; bool bOriginal = _saved[OneOf.title]; if (bOriginal == OneOf.value && changedCount > 0 && bChanged) { changedCount--; } else if (bOriginal != OneOf.value && bChanged) { changedCount++; } } else { section = OneOf.gameType == (int)EGameType.EGT_MAX ? games.Count - 1 : OneOf.gameType - 1; result = EditorGUILayout.Popup(section, games.ToArray(), new GUILayoutOption[] { GUILayout.MaxWidth(140) }); result = result == games.Count - 1 ? (int)EGameType.EGT_MAX : result + 1; bool bChanged = OneOf.gameType != result; OneOf.gameType = result; int Original = _savedGameType[OneOf.title]; if (Original == OneOf.gameType && changedCount > 0 && bChanged) { changedCount--; } else if (Original != OneOf.gameType && bChanged) { changedCount++; } } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } } GUILayout.EndVertical(); } GUILayout.EndScrollView(); } }
public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(); { BuildConfiger.Compress = EditorGUILayout.Toggle("Compress", BuildConfiger.Compress); BuildConfiger.DeterministicBundle = EditorGUILayout.Toggle("Deterministic", BuildConfiger.DeterministicBundle); BuildConfiger.BundleSuffix = EditorGUILayout.TextField("Bundle Suffix", BuildConfiger.BundleSuffix); DownloadConfiger.useCache = EditorGUILayout.Toggle("Use Unity Cache", DownloadConfiger.useCache); #if !(UNITY_4_2 || UNITY_4_1 || UNITY_4_0) GUI.enabled = DownloadConfiger.useCache; if (!DownloadConfiger.useCache) { DownloadConfiger.useCRC = false; DownloadConfiger.offlineCache = false; } DownloadConfiger.offlineCache = EditorGUILayout.Toggle("Offline Cache", DownloadConfiger.offlineCache); DownloadConfiger.useCRC = EditorGUILayout.Toggle("CRC Check", DownloadConfiger.useCRC); GUI.enabled = true; #endif DownloadConfiger.downloadThreadsCount = EditorGUILayout.IntField("Download Thread Limit", DownloadConfiger.downloadThreadsCount); DownloadConfiger.retryTime = EditorGUILayout.IntField("Error Retry Time", DownloadConfiger.retryTime); EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("Wizard Box")); { BuildConfiger.UseEditorTarget = EditorGUILayout.Toggle("Use Editor Target", BuildConfiger.UseEditorTarget); if (BuildConfiger.UseEditorTarget) { BuildConfiger.UnityBuildTarget = EditorUserBuildSettings.activeBuildTarget; } BuildPlatform origPlatform = BuildConfiger.BundleBuildTarget; GUI.enabled = !BuildConfiger.UseEditorTarget; BuildPlatform newPlatform = (BuildPlatform)EditorGUILayout.EnumPopup("Build Target", (System.Enum)origPlatform); GUI.enabled = true; if (origPlatform != newPlatform) { GUIUtility.keyboardControl = 0; // Remove the focuse on path text field BuildConfiger.BundleBuildTarget = newPlatform; PlayerPrefs.SetInt("BundleManagerPlatform", (int)newPlatform); } EditorGUILayout.BeginHorizontal(); { BuildConfiger.BuildOutputStr = EditorGUILayout.TextField("Output Path", BuildConfiger.BuildOutputStr); if (GUILayout.Button("...", GUILayout.MaxWidth(24))) { GUIUtility.keyboardControl = 0; // Remove the focuse on path text field string origPath = BuildConfiger.InterpretedOutputPath; string newOutputPath = EditorUtility.OpenFolderPanel("Choose Output Path", origPath, ""); if (newOutputPath != "" && newOutputPath != origPath) { BuildConfiger.BuildOutputStr = newOutputPath; } } } EditorGUILayout.EndHorizontal(); if (!DownloadConfiger.downloadFromOutput) { DownloadConfiger.downloadUrl = EditorGUILayout.TextField("Download Url", DownloadConfiger.downloadUrl); } DownloadConfiger.downloadFromOutput = EditorGUILayout.Toggle("Download from Output", DownloadConfiger.downloadFromOutput); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Export Config File To Output")) { BuildHelper.ExportBMDatasToOutput(); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndVertical(); if (GUI.changed) { BMDataAccessor.SaveBMConfiger(); BMDataAccessor.SaveUrls(); } }
static void GUI_ExInlcudes() { if (currentBundle.exIncludeGUIDs.Count > 0) { #if !(UNITY_4_2 || UNITY_4_1 || UNITY_4_0) m_FoldoutExIncludes = EditorGUILayout.Foldout(m_FoldoutExIncludes, "EXINCLUDE", BMGUIStyles.GetStyle("CFoldout")); #else m_FoldoutExIncludes = EditorGUILayout.Foldout(m_FoldoutExIncludes, "EXINCLUDE"); #endif } else { GUILayout.Label("EXINCLUDE", BMGUIStyles.GetStyle("UnfoldableTitle")); } if (!m_FoldoutExIncludes) { return; } EditorGUILayout.BeginVertical(); { foreach (var guid in currentBundle.exIncludeGUIDs) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); // bool isCurrentPathSelect = m_CurSelectAsset == guid && !m_IsMetaListSelect; AssetItemState itemState = GUI_AssetItem(assetPath, false, GetSharedIconOfInlucde(guid)); // if(itemState != AssetItemState.None) // { // if(!isCurrentPathSelect) // { // m_IsMetaListSelect = false; // m_CurSelectAsset = guid; // } // else if(itemState != AssetItemState.RClicked) // Only left click can disable selection // { // if(EditorApplication.timeSinceStartup - m_LastClickTime < 2f) // { // // Double clicked // EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof( Object ))); // } // else // { // m_CurSelectAsset = ""; // } // } // // m_LastClickTime = EditorApplication.timeSinceStartup; // Refresh(); // // // Right click //// if(itemState == AssetItemState.RClicked) //// { //// GenericMenu rightClickMenu = new GenericMenu(); //// rightClickMenu.AddItem(new GUIContent("Delete"), false, GUI_DeleteMenuCallback); //// rightClickMenu.DropDown(new Rect( Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0) ); //// } // } } } EditorGUILayout.EndVertical(); }
static void GUI_DependencyList() { var extra = currentBundle.GetExtraData(); if (!BMDataAccessor.DependencyUpdated) { GUILayout.Label("DEPEND", BMGUIStyles.GetStyle("UnfoldableTitle")); EditorGUILayout.HelpBox("Need Update Dependencies", MessageType.Info); return; } if (extra.dependGUIDs.Count > 0) { #if !(UNITY_4_2 || UNITY_4_1 || UNITY_4_0) m_FoldoutMetaFiles = EditorGUILayout.Foldout(m_FoldoutMetaFiles, "DEPEND", BMGUIStyles.GetStyle("CFoldout")); #else m_FoldoutMetaFiles = EditorGUILayout.Foldout(m_FoldoutMetaFiles, "DEPEND"); #endif } else { GUILayout.Label("DEPEND", BMGUIStyles.GetStyle("UnfoldableTitle")); return; } if (m_FoldoutMetaFiles) { EditorGUILayout.BeginVertical(); { foreach (string guid in extra.dependGUIDs) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); bool isCurrentPathSelect = m_CurSelectAsset == guid && m_IsMetaListSelect; var iconTexture = GetSharedIconOfDepend(guid); if (m_HideGreenDependencies && iconTexture && iconTexture.name == "sharedAsset") { continue; } if (GUI_AssetItem(assetPath, isCurrentPathSelect, iconTexture) != AssetItemState.None) { if (!isCurrentPathSelect) { m_IsMetaListSelect = true; m_CurSelectAsset = guid; } else { if (EditorApplication.timeSinceStartup - m_LastClickTime < 2f) { // Double clicked EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object))); } else { m_CurSelectAsset = ""; } } m_LastClickTime = EditorApplication.timeSinceStartup; Refresh(); } } } EditorGUILayout.EndVertical(); } }
public static void DrawInspector() { if (currentBundle == null) { GUILayout.FlexibleSpace(); GUILayout.Label("Select bundle to check its content."); GUILayout.FlexibleSpace(); return; } m_ScrollViewPosition = EditorGUILayout.BeginScrollView(m_ScrollViewPosition); { // Bundle type and version BundleBuildState buildStates = BundleManager.GetBuildStateOfBundle(currentBundle.name); EditorGUILayout.BeginHorizontal(); { string label = ""; switch (currentBundle.bundleType) { case BundleType.Normal: label = "Asset bundle"; break; case BundleType.Scene: label = "Scene bundle"; break; case BundleType.Text: label = "Text bundle"; break; default: throw new System.NotImplementedException(); } GUILayout.Label(label, BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); //GUILayout.Label("Version " + buildStates.version, BMGUIStyles.GetStyle("BoldLabel")); } EditorGUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { string sizeStr = "Build Size " + (buildStates.size == -1 ? "Unkown" : Mathf.CeilToInt(buildStates.size / 1024f) + " KB"); GUILayout.Label(sizeStr, BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); GUILayout.Label("Priority", EditorStyles.boldLabel); var priorityIndex = currentBundle.priority + 5; priorityIndex = EditorGUILayout.Popup(priorityIndex, PriorityNameList, GUILayout.MaxWidth(70)); currentBundle.priority = priorityIndex - 5; } GUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("Wizard Box")); { GUI_Inlcudes(); GUI_DependencyList(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); m_HideGreenDependencies = GUILayout.Toggle(m_HideGreenDependencies, "Hide Green", "button"); if (GUILayout.Button("Refresh") && currentBundle != null) { BundleManager.RefreshBundleDependencies(currentBundle); BMDataAccessor.SaveBundleData(); } } GUILayout.EndHorizontal(); }
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(); }
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); }