void InitCategoryList() { categories.Clear(); Dictionary <string, bool> catTable = new Dictionary <string, bool>(); // Parse and register category to table foreach (var preset in m_Presets) { preset.m_Resolution.m_Category = ScreenshotResolutionPresets.ParseCategory(preset); var c = preset.m_Resolution.m_Category; if (!c.Contains("Popularity") && !c.Contains("Collections")) { for (int i = 0; i < c.Length; ++i) { if (c[i] == '/') { catTable[c.Substring(0, i) + "/All"] = true; } } } catTable[preset.m_Resolution.m_Category] = true; } // Popularity presets foreach (PopularityPresetAsset popularity in m_Popularities) { catTable["Popularity/" + popularity.name] = true; } // Collections presets foreach (PresetCollectionAsset collection in m_Collections) { catTable["Collections/" + collection.name] = true; } // Update list categories = catTable.Keys.ToList(); categories.Insert(0, "All"); }
public virtual void DrawResolutionContentGUI() { if (m_Config.m_ShowResolutions == false) { return; } // Buttons EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Select all")) { m_Config.SelectAllResolutions(); EditorUtility.SetDirty(m_Obj); } if (GUILayout.Button("Deselect all")) { m_Config.ClearAllResolutions(); EditorUtility.SetDirty(m_Obj); } if (GUILayout.Button("Remove all")) { m_Config.RemoveAllResolutions(); EditorUtility.SetDirty(m_Obj); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set all Portait")) { m_Config.SetAllPortait(); EditorUtility.SetDirty(m_Obj); } if (GUILayout.Button("Set all Landscape")) { m_Config.SetAllLandscape(); EditorUtility.SetDirty(m_Obj); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); // if (m_IsDevice) { if (m_Expanded) { m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 8f; } else { m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 1f; } // if (GUILayout.Button ("Minimize")) { // m_Expanded = false; // } // } else { // if (GUILayout.Button ("Expand resolution settings")) { // m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 10f; // m_Expanded = true; // } // } // } // List m_ResolutionReorderableList.DoLayoutList(); EditorGUILayout.HelpBox("Use '+' to add preset(s) to the list. Note that your first click may take a few seconds.", MessageType.Info); if (GUILayout.Button("Export active resolution(s) as cutom preset(s)")) { ScreenshotResolutionPresets.ExportPresets(m_Config.GetActiveResolutions()); } }
void CreateResolutionReorderableList() { m_ResolutionReorderableList = new ReorderableList(serializedObject, m_Resolutions, true, true, true, true); if (m_IsDevice && m_Expanded) { m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 8f; } else { m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 1f; } m_ResolutionReorderableList.drawElementCallback = (Rect position, int index, bool active, bool focused) => { if (m_IsDevice) { DrawResolution(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index)); if (m_Expanded) { DrawResolutionName(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index)); DrawResolutionRes(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index)); DrawDeviceResolutionPPI(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index)); DrawResolutionOrientation(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index)); DrawDeviceCanvasResolution(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index)); } } else { SerializedProperty element = m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField(position, element); } }; m_ResolutionReorderableList.onChangedCallback = (ReorderableList list) => { m_Config.UpdateRatios(); EditorUtility.SetDirty(m_Obj); }; m_ResolutionReorderableList.onSelectCallback = (ReorderableList list) => { m_Config.UpdateRatios(); EditorUtility.SetDirty(m_Obj); }; m_ResolutionReorderableList.drawHeaderCallback = (Rect position) => { if (m_IsDevice) { EditorGUI.LabelField(position, ""); } else { EditorGUI.LabelField(position, "Active Width Height Scale Ratio Orientation Name"); } }; m_ResolutionReorderableList.onAddDropdownCallback = (Rect position, ReorderableList list) => { var menu = new GenericMenu(); ScreenshotResolutionPresets.Init(); ConstructResolutionPresetsMenu(menu); menu.AddItem(new GUIContent("new"), false, OnResolutionSelectCallback, new ScreenshotResolution()); menu.ShowAsContext(); }; }