-
Notifications
You must be signed in to change notification settings - Fork 869
Expand file tree
/
Copy pathVolumeDebugData.cs
More file actions
33 lines (29 loc) · 1.18 KB
/
VolumeDebugData.cs
File metadata and controls
33 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Reflection;
namespace UnityEngine.Rendering
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
internal static class VolumeDebugData
{
static Lazy<Dictionary<int, string>> debugIds = new(() => new Dictionary<int, string>());
internal static string GetVolumeParameterDebugId(VolumeParameter parameter)
{
return debugIds.Value.TryGetValue(parameter.fieldHash, out var debugId) ? debugId : string.Empty;
}
internal static void AddVolumeParameterDebugId(VolumeParameter parameter, FieldInfo field)
{
var fieldHash = field.GetHashCode();
parameter.fieldHash = fieldHash;
if (debugIds.Value.ContainsKey(fieldHash))
return;
var displayInfo = field.GetCustomAttribute<DisplayInfoAttribute>(true);
var debugId = displayInfo != null ? displayInfo.name : field.Name;
#if UNITY_EDITOR
debugId = UnityEditor.ObjectNames.NicifyVariableName(debugId); // In the editor, make the name more readable
#endif
debugIds.Value.Add(fieldHash, debugId);
}
}
#endif
}