You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
#if UNITY_EDITOR
|
|
|
|
using System;
|
|
using UnityEditor;
|
|
|
|
namespace UnityEngine.Rendering
|
|
{
|
|
public partial class VolumeComponent : IApplyRevertPropertyContextMenuItemProvider
|
|
{
|
|
public bool TryGetRevertMethodForFieldName(SerializedProperty property, out Action<SerializedProperty> revertMethod)
|
|
{
|
|
revertMethod = property =>
|
|
{
|
|
var targetObject = property.serializedObject.targetObject;
|
|
var type = targetObject.GetType();
|
|
var defaultVolumeComponent = (VolumeComponent) CreateInstance(type);
|
|
|
|
Undo.RecordObject(targetObject, $"Revert property {property.propertyPath} from {property.serializedObject}");
|
|
SerializedObject serializedObject = new SerializedObject(defaultVolumeComponent);
|
|
if (property.propertyType == SerializedPropertyType.ObjectReference)
|
|
{
|
|
property.objectReferenceValue = null;
|
|
}
|
|
else
|
|
{
|
|
var serializedProperty = serializedObject.FindProperty(property.propertyPath);
|
|
property.serializedObject.CopyFromSerializedProperty(serializedProperty);
|
|
VolumeManager.instance.OnVolumeComponentChanged(targetObject as VolumeComponent);
|
|
}
|
|
|
|
property.serializedObject.ApplyModifiedProperties();
|
|
};
|
|
|
|
return true;
|
|
}
|
|
|
|
public string GetSourceTerm()
|
|
{
|
|
return "Property";
|
|
}
|
|
|
|
public bool TryGetApplyMethodForFieldName(SerializedProperty property, out Action<SerializedProperty> applyMethod)
|
|
{
|
|
applyMethod = null;
|
|
return false;
|
|
}
|
|
|
|
public string GetSourceName(Component comp)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|
|
#endif
|