private void DrawToolbar() { EditorGUILayout.BeginHorizontal("toolbar", GUILayout.ExpandWidth(true)); { if (GUILayout.Button(isExpandAll ? "Collapse All" : "Expand All", EditorStyles.toolbarButton, GUILayout.Width(Styles.ToolbarBtnWidth))) { isExpandAll = !isExpandAll; if (isExpandAll) { assetPackerTreeView.ExpandAll(); } else { assetPackerTreeView.CollapseAll(); } } Rect menuRect = GUILayoutUtility.GetRect(Contents.RunModeContent, EditorStyles.toolbarButton); if (EditorGUI.DropdownButton(menuRect, Contents.RunModeContent, FocusType.Passive, EditorStyles.toolbarButton)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(RunMode.AssetDatabase.ToString()), runMode == RunMode.AssetDatabase, () => { PlayerSettingsUtility.RemoveScriptingDefineSymbol(ASSET_BUNDLE_SYMBOL); }); menu.AddItem(new GUIContent(RunMode.AssetBundle.ToString()), runMode == RunMode.AssetBundle, () => { PlayerSettingsUtility.AddScriptingDefineSymbol(ASSET_BUNDLE_SYMBOL); }); menu.DropDown(menuRect); } GUILayout.FlexibleSpace(); if (searchField == null) { searchField = new ToolbarSearchField((text) => { if (searchText != text) { searchText = text; SetTreeModel(); } }, (category) => { int newIndex = Array.IndexOf(SearchCategories, category); if ((int)searchCategory != newIndex) { searchCategory = (SearchCategory)newIndex; SetTreeModel(); } }); searchField.Categories = SearchCategories; searchField.CategoryIndex = 0; } searchField.OnGUILayout(); } EditorGUILayout.EndHorizontal(); }
//private Dictionary<string, List<PackerBundleData>> addressRepeatDataDic = new Dictionary<string, List<PackerBundleData>>(); private void OnEnable() { packerData = AssetPackerUtil.GetPackerData(); //foreach(var group in assetPackerConfig.groupDatas) //{ // foreach(var data in group.assetFiles) // { // if(!addressRepeatDataDic.TryGetValue(data.Address,out List<PackerBundleData> dataList)) // { // dataList = new List<PackerBundleData>(); // addressRepeatDataDic.Add(data.Address, dataList); // } // dataList.Add(data); // } //} if (PlayerSettingsUtility.HasScriptingDefineSymbol(ASSET_BUNDLE_SYMBOL)) { runMode = RunMode.AssetBundle; } }
private void OnEnable() { assetPackerConfig = AssetPackerUtil.GetAssetPackerConfig(); foreach (var group in assetPackerConfig.groupDatas) { foreach (var data in group.assetFiles) { if (!addressRepeatDataDic.TryGetValue(data.assetAddress, out List <AssetPackerAddressData> dataList)) { dataList = new List <AssetPackerAddressData>(); addressRepeatDataDic.Add(data.assetAddress, dataList); } dataList.Add(data); } } if (PlayerSettingsUtility.HasScriptingDefineSymbol(ASSET_BUNDLE_SYMBOL)) { runMode = RunMode.AssetBundle; } }
/// <summary> /// EnsureSetup will rerun the AddConvention initialization process to create the necessary folder /// desired by the project, tools, and frameworks reliant on it. /// </summary> public static void EnsureSetup() { // Initialize any root domain folders and paths if (!Directory.Exists(Path.Combine(COCUtility.GetUnityAssetRoot(), COCUtility.GAME_ASSET_ROOT))) { COCUtility.CreateGameRoot(); } var allCOCDomains = (COCDomain[])Enum.GetValues(typeof(COCDomain)); foreach (var cocDomain in allCOCDomains) { var relativeFolderPath = COCUtility.GetGamePath(cocDomain); var absoluteFolderPath = Path.Combine(COCUtility.GetUnityAssetRoot(), relativeFolderPath); if (!Directory.Exists(absoluteFolderPath)) { Directory.CreateDirectory(absoluteFolderPath); Debug.LogFormat("[COC] Folder created at \"{0}\"", absoluteFolderPath); } COCUtility.PreserveFolder(COCUtility.GetGamePath(cocDomain)); } // Set the scripting symbol for COC PlayerSettingsUtility.AddScriptingSymbolIfNotDefined(SCRIPTING_SYMBOL); // Search through the project for all derived classes of COCProviderBase // and add their conventions to the project var cocProviders = ReflectionUtility.GetAllDerivedInstancesOfType <COCProviderBase>(); foreach (var cocProvider in cocProviders) { cocProvider.AddConventions(); } AssetDatabase.Refresh(); }