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.

50 lines
1.7 KiB

  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace OVR
  4. {
  5. /*
  6. -----------------------
  7. MixerSnapshotPropertyDrawer
  8. -----------------------
  9. */
  10. [CustomPropertyDrawer( typeof( MixerSnapshot ) )]
  11. public class MixerSnapshotPropertyDrawer : PropertyDrawer {
  12. // Draw the property inside the given rect
  13. public override void OnGUI( Rect position, SerializedProperty property, GUIContent label ) {
  14. // Using BeginProperty / EndProperty on the parent property means that
  15. // prefab override logic works on the entire property.
  16. EditorGUI.BeginProperty( position, label, property );
  17. // Draw label
  18. position = EditorGUI.PrefixLabel( position, GUIUtility.GetControlID( FocusType.Passive ), label );
  19. // Don't make child fields be indented
  20. var indent = EditorGUI.indentLevel;
  21. EditorGUI.indentLevel = 0;
  22. EditorGUIUtility.labelWidth = 65;
  23. float width = ( position.width - 15.0f ) / 2.0f;
  24. // Calculate rects
  25. var srcRect = new Rect( position.x, position.y, width + 20, position.height ); position.x += width + 25.0f;
  26. var destRect = new Rect( position.x, position.y, width - 60, position.height ); position.x += width - 60.0f;
  27. var secsRect = new Rect( position.x, position.y, 40, position.height );
  28. // Draw fields - pass GUIContent.none to each so they are drawn without labels
  29. EditorGUI.PropertyField( srcRect, property.FindPropertyRelative( "snapshot" ), GUIContent.none );
  30. EditorGUI.PropertyField( destRect, property.FindPropertyRelative( "transitionTime" ), new GUIContent( "Transition" ) );
  31. EditorGUI.LabelField( secsRect, new GUIContent( "sec(s)" ) );
  32. // Set indent back to what it was
  33. EditorGUI.indentLevel = indent;
  34. EditorGUI.EndProperty();
  35. }
  36. }
  37. } // namespace OVR