| 1 | using UnityEngine; |
| 2 | using UnityEditor; |
| 3 | using System.Collections; |
| 4 | |
| 5 | namespace OVR |
| 6 | { |
| 7 | |
| 8 | /* |
| 9 | ----------------------- |
| 10 | |
| 11 | OSPPropsPropertyDrawer |
| 12 | |
| 13 | ----------------------- |
| 14 | */ |
| 15 | [CustomPropertyDrawer(typeof(OSPProps))] |
| 16 | public class OSPPropsPropertyDrawer : PropertyDrawer { |
| 17 | |
| 18 | static float lineHeight = EditorGUIUtility.singleLineHeight + 2.0f; |
| 19 | static float indent = 32.0f; |
| 20 | // TODO - some day just enumerate these |
| 21 | static string[] props = new string[] { "useFastOverride", "gain", "enableInvSquare", "volumetric" , "invSquareFalloff" }; |
| 22 | static string[] names = new string[] { "Reflections Enabled", "Gain", "Enable Oculus Atten.", "Volumetric", "Range" }; |
| 23 | static int[] lines = new int[] { 1, 1, 1, 1, 2, 2 }; |
| 24 | /* |
| 25 | ----------------------- |
| 26 | OnGUI() |
| 27 | ----------------------- |
| 28 | */ |
| 29 | public override void OnGUI( Rect position, SerializedProperty prop, GUIContent label ) { |
| 30 | SerializedProperty playSpatializedProp = prop.FindPropertyRelative("enableSpatialization"); |
| 31 | position.height = lineHeight; |
| 32 | EditorGUI.PropertyField( position, playSpatializedProp ); |
| 33 | if ( playSpatializedProp.boolValue ) { |
| 34 | position.y += lineHeight + 4.0f; |
| 35 | Rect posLine = position; |
| 36 | posLine.x += indent; |
| 37 | posLine.width -= indent; |
| 38 | posLine.height = 1f; |
| 39 | GUI.Box( posLine, "" ); |
| 40 | position.y -= 10.0f; |
| 41 | for ( int i = 0; i < props.Length; i++ ) { |
| 42 | position.y += lineHeight; |
| 43 | position.height = ( lineHeight * lines[i] ); |
| 44 | SerializedProperty sibling = prop.FindPropertyRelative( props[i] ); |
| 45 | EditorGUI.PropertyField( position, sibling, new GUIContent( names[i] ) ); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | ----------------------- |
| 52 | GetPropertyHeight() |
| 53 | ----------------------- |
| 54 | */ |
| 55 | public override float GetPropertyHeight (SerializedProperty prop, GUIContent label) { |
| 56 | SerializedProperty playSpatializedProp = prop.FindPropertyRelative("enableSpatialization"); |
| 57 | if ( !playSpatializedProp.boolValue ) { |
| 58 | return base.GetPropertyHeight( prop, label ); |
| 59 | } else { |
| 60 | return base.GetPropertyHeight( prop, label ) + ( lineHeight * ( props.Length + 1 ) ) + 16.0f; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | } |
| 65 | |
| 66 | } // namespace OVR |