BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / AudioManager / Scripts / Audio / Editor / MixerSnapshotPropertyDrawer.cs

MixerSnapshotPropertyDrawer.cs

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