-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ME] Add
Category
attribute, SortPropertiesByType
, `SortPropertie…
…sByAlphabet` config and color work (#302) - Add property `Category` attribute to the shader manifest. - Add two configs: `SortPropertiesByType` and `SortPropertiesByAlphabet` to control the property sorting. - Add different colors to separator items to improve distinction in a lengthy context. - Update shader manifest template. * [ME] Add property `Category` attribute and two configs: `SortPropertiesByType` and `SortPropertiesByAlphabet` * [ME] Add different colors to separator items to improve distinction in a lengthy context * [ME] Update shader manifest template * [ME] Some optimizations * Some formatting for merging this * [ME] Change the config name to `SortPropertiesByName` * Formatting * Consistent style * [ME] Add a data holder `PropertyOrganizer` to avoid repeated grouping and sorting. * [ME] Hide categories without properties due to blacklist or property filtering
- Loading branch information
Showing
10 changed files
with
2,117 additions
and
1,983 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using UnityEngine; | ||
using System.Linq; | ||
using static MaterialEditorAPI.MaterialEditorPluginBase; | ||
|
||
namespace MaterialEditorAPI | ||
{ | ||
internal class PropertyOrganizer | ||
{ | ||
// Shader, category, property | ||
internal static Dictionary<string, Dictionary<string, List<ShaderPropertyData>>> PropertyOrganization = new Dictionary<string, Dictionary<string, List<ShaderPropertyData>>>(); | ||
internal static string UncategorizedName = "Uncategorized"; | ||
internal static void Refresh() { | ||
foreach (var shader in XMLShaderProperties) | ||
{ | ||
PropertyOrganization[shader.Key] = shader.Value | ||
.Where(kv => !kv.Value.Hidden) | ||
.GroupBy(kv => string.IsNullOrEmpty(kv.Value.Category) ? UncategorizedName : char.ToUpper(kv.Value.Category[0]) + kv.Value.Category.Substring(1)) | ||
.OrderBy(g => g.Key == UncategorizedName ? 1 : 0) // Ensure "Uncategorized" goes to the end | ||
.ToDictionary( | ||
g => g.Key, | ||
g => | ||
{ | ||
var kvs = g.AsEnumerable(); | ||
if (SortPropertiesByType.Value && SortPropertiesByName.Value) | ||
{ | ||
kvs = kvs.OrderBy(kv => kv.Value.Type).ThenBy(kv => kv.Value.Name); | ||
} | ||
else if (SortPropertiesByType.Value) | ||
{ | ||
kvs = kvs.OrderBy(kv => kv.Value.Type); | ||
} | ||
else if (SortPropertiesByName.Value) | ||
{ | ||
kvs = kvs.OrderBy(kv => kv.Value.Name); | ||
} | ||
return kvs.Select(kv=>kv.Value).ToList(); | ||
} | ||
); | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.