Assignment for RMIT Mixed Reality in 2020
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.

36 lines
1020 B

  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. public class RemapSliders : MaterialPropertyDrawer
  7. {
  8. public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
  9. {
  10. EditorGUI.BeginChangeCheck();
  11. Vector4 value = prop.vectorValue;
  12. EditorGUI.showMixedValue = prop.hasMixedValue;
  13. var cacheLabel = EditorGUIUtility.labelWidth;
  14. var cacheField = EditorGUIUtility.fieldWidth;
  15. if( cacheField <= 64 )
  16. {
  17. float total = position.width;
  18. EditorGUIUtility.labelWidth = Mathf.Ceil( 0.45f * total ) - 30;
  19. EditorGUIUtility.fieldWidth = Mathf.Ceil( 0.55f * total ) + 30;
  20. }
  21. EditorGUILayout.MinMaxSlider( label, ref value.x, ref value.y, 0, 1 );
  22. EditorGUIUtility.labelWidth = cacheLabel;
  23. EditorGUIUtility.fieldWidth = cacheField;
  24. EditorGUI.showMixedValue = false;
  25. if( EditorGUI.EndChangeCheck() )
  26. {
  27. prop.vectorValue = value;
  28. }
  29. }
  30. }