A game about forced loneliness, made by TACStudios
1#if UNITY_EDITOR
2
3using System;
4using UnityEditor;
5
6namespace UnityEngine.Rendering
7{
8 public partial class VolumeComponent : IApplyRevertPropertyContextMenuItemProvider
9 {
10 public bool TryGetRevertMethodForFieldName(SerializedProperty property, out Action<SerializedProperty> revertMethod)
11 {
12 revertMethod = property =>
13 {
14 var targetObject = property.serializedObject.targetObject;
15 var type = targetObject.GetType();
16 var defaultVolumeComponent = (VolumeComponent) CreateInstance(type);
17
18 Undo.RecordObject(targetObject, $"Revert property {property.propertyPath} from {property.serializedObject}");
19 SerializedObject serializedObject = new SerializedObject(defaultVolumeComponent);
20 if (property.propertyType == SerializedPropertyType.ObjectReference)
21 {
22 property.objectReferenceValue = null;
23 }
24 else
25 {
26 var serializedProperty = serializedObject.FindProperty(property.propertyPath);
27 property.serializedObject.CopyFromSerializedProperty(serializedProperty);
28 VolumeManager.instance.OnVolumeComponentChanged(targetObject as VolumeComponent);
29 }
30
31 property.serializedObject.ApplyModifiedProperties();
32 };
33
34 return true;
35 }
36
37 public string GetSourceTerm()
38 {
39 return "Property";
40 }
41
42 public bool TryGetApplyMethodForFieldName(SerializedProperty property, out Action<SerializedProperty> applyMethod)
43 {
44 applyMethod = null;
45 return false;
46 }
47
48 public string GetSourceName(Component comp)
49 {
50 return string.Empty;
51 }
52 }
53}
54#endif