LiftGammaGainEditor.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. using UnityEngine.Rendering.Universal;
  3. namespace UnityEditor.Rendering.Universal
  4. {
  5. [VolumeComponentEditor(typeof(LiftGammaGain))]
  6. sealed class LiftGammaGainEditor : VolumeComponentEditor
  7. {
  8. SerializedDataParameter m_Lift;
  9. SerializedDataParameter m_Gamma;
  10. SerializedDataParameter m_Gain;
  11. readonly TrackballUIDrawer m_TrackballUIDrawer = new TrackballUIDrawer();
  12. public override void OnEnable()
  13. {
  14. var o = new PropertyFetcher<LiftGammaGain>(serializedObject);
  15. m_Lift = Unpack(o.Find(x => x.lift));
  16. m_Gamma = Unpack(o.Find(x => x.gamma));
  17. m_Gain = Unpack(o.Find(x => x.gain));
  18. }
  19. public override void OnInspectorGUI()
  20. {
  21. if (UniversalRenderPipeline.asset?.postProcessingFeatureSet == PostProcessingFeatureSet.PostProcessingV2)
  22. {
  23. EditorGUILayout.HelpBox(UniversalRenderPipelineAssetEditor.Styles.postProcessingGlobalWarning, MessageType.Warning);
  24. return;
  25. }
  26. using (new EditorGUILayout.HorizontalScope())
  27. {
  28. m_TrackballUIDrawer.OnGUI(m_Lift.value, m_Lift.overrideState, EditorGUIUtility.TrTextContent("Lift"), GetLiftValue);
  29. GUILayout.Space(4f);
  30. m_TrackballUIDrawer.OnGUI(m_Gamma.value, m_Gamma.overrideState, EditorGUIUtility.TrTextContent("Gamma"), GetLiftValue);
  31. GUILayout.Space(4f);
  32. m_TrackballUIDrawer.OnGUI(m_Gain.value, m_Gain.overrideState, EditorGUIUtility.TrTextContent("Gain"), GetLiftValue);
  33. }
  34. }
  35. static Vector3 GetLiftValue(Vector4 x) => new Vector3(x.x + x.w, x.y + x.w, x.z + x.w);
  36. }
  37. }