Skip to content

Commit dc212d9

Browse files
authored
[ME] Add category (#371)
1 parent 351ec3b commit dc212d9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/MaterialEditor.Base/PluginBase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public partial class MaterialEditorPluginBase : BaseUnityPlugin
106106
/// </summary>
107107
public static ConfigEntry<bool> SortPropertiesByName { get; set; }
108108
/// <summary>
109+
/// Whether to sort shader properties by their category
110+
/// </summary>
111+
public static ConfigEntry<bool> SortPropertiesByCategory { get; set; }
112+
/// <summary>
109113
/// Controls the max value of the slider for this projector property
110114
/// </summary>
111115
public static ConfigEntry<float> ProjectorNearClipPlaneMax { get; set; }
@@ -153,6 +157,7 @@ public virtual void Awake()
153157
Showtooltips = Config.Bind("Config", "Show Tooltips", true, "Whether to show tooltips or not");
154158
SortPropertiesByType = Config.Bind("Config", "Sort Properties by Type", true, "Whether to sort shader properties by their types.");
155159
SortPropertiesByName = Config.Bind("Config", "Sort Properties by Name", true, "Whether to sort shader properties by their names.");
160+
SortPropertiesByCategory = Config.Bind("Config", "Sort Properties by Category", true, "Whether to sort shader properties by their category.");
156161
ConvertNormalmapsOnExport = Config.Bind("Config", "Convert Normalmaps On Export", true, new ConfigDescription("When enabled, normalmaps get converted from DXT5 compressed (red) normals back to normal OpenGL (blue/purple) normals"));
157162

158163
//Everything in these games is 10x the size of KK/KKS
@@ -177,6 +182,7 @@ public virtual void Awake()
177182
ConfigExportPath.SettingChanged += ConfigExportPath_SettingChanged;
178183
SortPropertiesByType.SettingChanged += (object sender, EventArgs e) => PropertyOrganizer.Refresh();
179184
SortPropertiesByName.SettingChanged += (object sender, EventArgs e) => PropertyOrganizer.Refresh();
185+
SortPropertiesByCategory.SettingChanged += (object sender, EventArgs e) => PropertyOrganizer.Refresh();
180186
SetExportPath();
181187

182188
ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, AssetLoadedHook);

src/MaterialEditor.Base/UI/UI.PropertyOrganizer.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using UnityEngine;
1+
using System.Collections.Generic;
52
using System.Linq;
63
using static MaterialEditorAPI.MaterialEditorPluginBase;
74

@@ -17,7 +14,7 @@ internal static void Refresh() {
1714
{
1815
PropertyOrganization[shader.Key] = shader.Value
1916
.Where(kv => !kv.Value.Hidden)
20-
.GroupBy(kv => string.IsNullOrEmpty(kv.Value.Category) ? UncategorizedName : char.ToUpper(kv.Value.Category[0]) + kv.Value.Category.Substring(1))
17+
.GroupBy(kv => (string.IsNullOrEmpty(kv.Value.Category) || !SortPropertiesByCategory.Value) ? UncategorizedName : char.ToUpper(kv.Value.Category[0]) + kv.Value.Category.Substring(1))
2118
.OrderBy(g => g.Key == UncategorizedName ? 1 : 0) // Ensure "Uncategorized" goes to the end
2219
.ToDictionary(
2320
g => g.Key,

0 commit comments

Comments
 (0)