LuxURPVectorTwoInverseDrawer.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. public class LuxURPVectorTwoInverseDrawer : MaterialPropertyDrawer {
  5. public override void OnGUI (Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
  6. // Needed since Unity 2019
  7. EditorGUIUtility.labelWidth = 0;
  8. Vector4 vec4value = new Vector4(prop.vectorValue.y, prop.vectorValue.x, 0, 0);
  9. float near = prop.vectorValue.y;
  10. float far = prop.vectorValue.x;
  11. GUILayout.Space(-18);
  12. EditorGUI.BeginChangeCheck();
  13. EditorGUILayout.BeginVertical();
  14. EditorGUILayout.BeginHorizontal();
  15. EditorGUILayout.PrefixLabel(label);
  16. GUILayout.Space(-1);
  17. vec4value = EditorGUILayout.Vector2Field ("", vec4value);
  18. EditorGUILayout.EndHorizontal();
  19. near = EditorGUILayout.FloatField ("n", near);
  20. far = EditorGUILayout.FloatField ("f", far);
  21. EditorGUILayout.EndVertical();
  22. // GUILayout.Space(2);
  23. if (EditorGUI.EndChangeCheck ()) {
  24. prop.vectorValue = vec4value; //new Vector4(vec4value.x, vec4value.y, 0, 0);
  25. prop.vectorValue = new Vector4(far, near, 0, 0);
  26. }
  27. }
  28. }