MediaHintsDrawer.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. namespace RenderHeads.Media.AVProVideo.Editor
  6. {
  7. [CustomPropertyDrawer(typeof(MediaHints))]
  8. public class MediaHintsDrawer : PropertyDrawer
  9. {
  10. private readonly static GUIContent[] StereoPackingOptions =
  11. {
  12. // NOTE: must be in the same order as enum StereoPacking
  13. new GUIContent("None"),
  14. new GUIContent("Top Bottom"),
  15. new GUIContent("Left Right"),
  16. new GUIContent("Custom UV"),
  17. };
  18. public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { return 0f; }
  19. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  20. {
  21. EditorGUI.BeginProperty(position, GUIContent.none, property);
  22. SerializedProperty propHintsTransparency = property.FindPropertyRelative("transparency");
  23. SerializedProperty propHintsAlphaPacking = property.FindPropertyRelative("alphaPacking");
  24. SerializedProperty propHintsStereoPacking = property.FindPropertyRelative("stereoPacking");
  25. EditorGUILayout.PropertyField(propHintsTransparency);
  26. if ((TransparencyMode)propHintsTransparency.enumValueIndex == TransparencyMode.Transparent)
  27. {
  28. EditorGUILayout.PropertyField(propHintsAlphaPacking);
  29. }
  30. {
  31. // NOTE: We don't allow selection of 'Two Textures' as this mode is only produced by the Players as it is platform specific
  32. propHintsStereoPacking.enumValueIndex = EditorGUILayout.Popup(new GUIContent("Stereo Packing"), propHintsStereoPacking.enumValueIndex, StereoPackingOptions);
  33. }
  34. EditorGUI.EndProperty();
  35. }
  36. }
  37. }