| 1 | using UnityEngine; |
| 2 | using UnityEditor; |
| 3 | using System.Collections; |
| 4 | |
| 5 | namespace OVR |
| 6 | { |
| 7 | |
| 8 | /* |
| 9 | ----------------------- |
| 10 | |
| 11 | SoundFXPropertyDrawer |
| 12 | |
| 13 | ----------------------- |
| 14 | */ |
| 15 | [CustomPropertyDrawer(typeof(SoundFX))] |
| 16 | public class SoundFXPropertyDrawer : PropertyDrawer { |
| 17 | |
| 18 | static float lineHeight = EditorGUIUtility.singleLineHeight + 2.0f; |
| 19 | |
| 20 | static string[] props = new string[] { "name", "playback", "volume", "pitchVariance", "falloffDistance", "falloffCurve", "reverbZoneMix", "spread", "pctChanceToPlay", "priority", "delay", "looping", "ospProps", "soundClips" }; |
| 21 | |
| 22 | /* |
| 23 | ----------------------- |
| 24 | OnGUI() |
| 25 | ----------------------- |
| 26 | */ |
| 27 | public override void OnGUI( Rect position, SerializedProperty prop, GUIContent label ) { |
| 28 | |
| 29 | EditorGUILayout.BeginVertical(); |
| 30 | for ( int i = 0; i < props.Length; i++ ) { |
| 31 | EditorGUI.indentLevel = 2; |
| 32 | SerializedProperty property = prop.FindPropertyRelative( props[i] ); |
| 33 | if ( props[i] == "reverbZoneMix" ) { |
| 34 | EditorGUILayout.BeginHorizontal(); |
| 35 | SerializedProperty reverbCurve = prop.FindPropertyRelative( "reverbZoneMix" ); |
| 36 | EditorGUILayout.PropertyField( reverbCurve, true, GUILayout.Width( Screen.width - 130.0f ) ); |
| 37 | if ( GUILayout.Button( "Reset", GUILayout.Width( 50.0f ) ) ) { |
| 38 | reverbCurve.animationCurveValue = new AnimationCurve( new Keyframe[2] { new Keyframe( 0f, 1.0f ), new Keyframe( 1f, 1f ) } ); |
| 39 | } |
| 40 | EditorGUILayout.EndHorizontal(); |
| 41 | } else { |
| 42 | EditorGUILayout.PropertyField( property, true, GUILayout.Width( Screen.width - 80.0f ) ); |
| 43 | position.y += lineHeight + 4.0f; |
| 44 | if ( props[i] == "falloffCurve" ) { |
| 45 | if ( property.enumValueIndex == (int)AudioRolloffMode.Custom ) { |
| 46 | EditorGUILayout.PropertyField( prop.FindPropertyRelative( "volumeFalloffCurve" ), true, GUILayout.Width( Screen.width - 80.0f ) ); |
| 47 | position.y += lineHeight + 4.0f; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | EditorGUILayout.EndVertical(); |
| 53 | GUILayout.Space( 5.0f ); |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | ----------------------- |
| 58 | GetPropertyHeight() |
| 59 | ----------------------- |
| 60 | */ |
| 61 | public override float GetPropertyHeight (SerializedProperty prop, GUIContent label) { |
| 62 | return base.GetPropertyHeight( prop, label ); |
| 63 | } |
| 64 | |
| 65 | } |
| 66 | |
| 67 | } // namespace OVR |