Skip to content

Commit dfd5950

Browse files
committed
add a public API for registering debug id => name entries
1 parent c262031 commit dfd5950

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

Source/DynamicProperties/MaterialPropertyManager.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ private void OnDestroy()
5050

5151
#endregion
5252

53+
#region Public API
54+
5355
public bool Set(Renderer renderer, Props props)
5456
{
5557
if (renderer == null) {
@@ -75,7 +77,15 @@ public bool Remove(Renderer renderer)
7577
return rendererCascades.Remove(renderer);
7678
}
7779

78-
public bool Remove(Props props)
80+
public static void RegisterPropertyNamesForDebugLogging(params string[] properties)
81+
{
82+
foreach (var property in properties) PropIdToName.Register(property);
83+
}
84+
85+
#endregion
86+
87+
/// Public API equivalent is calling `Props.Dispose`.
88+
internal bool Remove(Props props)
7989
{
8090
var removed = false;
8191

Source/DynamicProperties/Prop.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ namespace Shabby.DynamicProperties;
66

77
internal static class PropIdToName
88
{
9-
private static readonly string[] CommonProperties = [
10-
"TransparentFX",
9+
private static readonly string[] StockProperties = [
1110
"_BumpMap",
1211
"_Color",
1312
"_EmissiveColor",
@@ -20,27 +19,18 @@ internal static class PropIdToName
2019
"_Opacity",
2120
"_RimColor",
2221
"_RimFalloff",
23-
"_TC1Color",
24-
"_TC1MetalBlend",
25-
"_TC1Metalness",
26-
"_TC1SmoothBlend",
27-
"_TC1Smoothness",
28-
"_TC2Color",
29-
"_TC2MetalBlend",
30-
"_TC2Metalness",
31-
"_TC2SmoothBlend",
32-
"_TC2Smoothness",
3322
"_TemperatureColor",
34-
"_Tex",
35-
"_Tint",
3623
"_TintColor",
3724
"_subdiv",
3825
"localMatrix",
3926
"upMatrix"
4027
];
4128

4229
private static readonly Dictionary<int, string> IdToName =
43-
CommonProperties.ToDictionary(Shader.PropertyToID, name => name);
30+
StockProperties.ToDictionary(Shader.PropertyToID, name => name);
31+
32+
internal static void Register(string property) =>
33+
IdToName[Shader.PropertyToID(property)] = property;
4434

4535
internal static string Get(int id) =>
4636
IdToName.TryGetValue(id, out var name) ? name : $"<{id}>";

0 commit comments

Comments
 (0)