3
3
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4
4
5
5
using System ;
6
- using System . IO ;
7
6
using System . Linq ;
8
- using System . Runtime . InteropServices ;
9
7
using UnityEditorInternal ;
10
- using System . Collections . Generic ;
11
8
using UnityEngine ;
12
9
using UnityEngine . Audio ;
13
10
using UnityEngine . Playables ;
@@ -37,6 +34,7 @@ private static class Styles
37
34
private SerializedProperty m_UpdateMethod ;
38
35
39
36
private GUIContent m_AnimatorContent ;
37
+ private GUIContent m_AudioContent ;
40
38
private GUIContent m_ScriptContent ;
41
39
private Texture m_DefaultScriptContentTexture ;
42
40
@@ -49,6 +47,7 @@ public void OnEnable()
49
47
m_InitialTime = serializedObject . FindProperty ( "m_InitialTime" ) ;
50
48
51
49
m_AnimatorContent = new GUIContent ( AssetPreview . GetMiniTypeThumbnail ( typeof ( Animator ) ) ) ;
50
+ m_AudioContent = new GUIContent ( AssetPreview . GetMiniTypeThumbnail ( typeof ( AudioSource ) ) ) ;
52
51
m_ScriptContent = new GUIContent ( EditorGUIUtility . LoadIcon ( "ScriptableObject Icon" ) ) ;
53
52
m_DefaultScriptContentTexture = m_ScriptContent . image ;
54
53
}
@@ -84,7 +83,6 @@ public override void OnInspectorGUI()
84
83
}
85
84
}
86
85
87
-
88
86
PropertyFieldAsFloat ( m_InitialTime , Styles . InitialTimeContent ) ;
89
87
90
88
if ( Application . isPlaying )
@@ -112,6 +110,15 @@ private void BindingInspector(PlayableBinding binding, PlayableDirector director
112
110
113
111
if ( binding . streamType == DataStreamType . Audio )
114
112
{
113
+ AudioSource source = director . GetGenericBinding ( binding . sourceObject ) as AudioSource ;
114
+ m_AudioContent . text = binding . streamName ;
115
+ m_AudioContent . tooltip = ( source == null ) ? Styles . NoBindingsContent . text : string . Empty ;
116
+ EditorGUI . BeginChangeCheck ( ) ;
117
+ source = EditorGUILayout . ObjectField ( m_AudioContent , source , typeof ( AudioSource ) , false ) as AudioSource ;
118
+ if ( EditorGUI . EndChangeCheck ( ) )
119
+ {
120
+ SetBinding ( director , binding . sourceObject , source ) ;
121
+ }
115
122
}
116
123
else if ( binding . streamType == DataStreamType . Animation )
117
124
{
@@ -193,6 +200,8 @@ private static void PlayableAssetField(SerializedProperty property, GUIContent t
193
200
if ( EditorGUI . EndChangeCheck ( ) )
194
201
{
195
202
property . objectReferenceValue = prop ;
203
+ // some editors (like Timeline) needs to repaint when the playable asset changes
204
+ InternalEditorUtility . RepaintAllViews ( ) ;
196
205
}
197
206
198
207
EditorGUI . EndProperty ( ) ;
0 commit comments