RemapSlidersFull.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System;
  6. namespace AmplifyShaderEditor
  7. {
  8. public class RemapSlidersFull : MaterialPropertyDrawer
  9. {
  10. public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
  11. {
  12. EditorGUI.BeginChangeCheck();
  13. Vector4 value = prop.vectorValue;
  14. EditorGUI.showMixedValue = prop.hasMixedValue;
  15. var cacheLabel = EditorGUIUtility.labelWidth;
  16. var cacheField = EditorGUIUtility.fieldWidth;
  17. if ( cacheField <= 64 )
  18. {
  19. float total = position.width;
  20. EditorGUIUtility.labelWidth = Mathf.Ceil( 0.45f * total ) - 30;
  21. EditorGUIUtility.fieldWidth = Mathf.Ceil( 0.55f * total ) + 30;
  22. }
  23. EditorGUI.MinMaxSlider( position, label, ref value.x, ref value.y, value.z, value.w );
  24. EditorGUIUtility.labelWidth = cacheLabel;
  25. EditorGUIUtility.fieldWidth = cacheField;
  26. EditorGUI.showMixedValue = false;
  27. if ( EditorGUI.EndChangeCheck() )
  28. {
  29. prop.vectorValue = value;
  30. }
  31. }
  32. }
  33. }