public static void SetSceneGameObject(PlayableDirector director, TrackAsset asset, GameObject go) { if (director == null || asset == null) { return; } asset = GetSceneReferenceTrack(asset); var bindings = asset.outputs; if (bindings.Count() == 0) { return; } var binding = bindings.First(); if (binding.outputTargetType == typeof(GameObject)) { BindingUtility.Bind(director, asset, go); } else { BindingUtility.Bind(director, asset, TimelineHelpers.AddRequiredComponent(go, asset)); } }
static void PasteTracks() { var trackData = TimelineEditor.clipboard.GetTracks().ToList(); if (trackData.Any()) { SelectionManager.RemoveTimelineSelection(); } foreach (var track in trackData) { var newTrack = track.item.Duplicate(TimelineEditor.clipboard.exposedPropertyTable, TimelineEditor.inspectedDirector, TimelineEditor.inspectedAsset); if (track.binding != null) { BindingUtility.Bind(TimelineEditor.inspectedDirector, newTrack, track.binding); } SelectionManager.Add(newTrack); foreach (var childTrack in newTrack.GetFlattenedChildTracks()) { SelectionManager.Add(childTrack); } if (track.parent != null && track.parent.timelineAsset == TimelineEditor.inspectedAsset) { TrackExtensions.ReparentTracks(new List <TrackAsset> { newTrack }, track.parent, track.item); } } }
static void ObjectBindingField(Rect position, Object obj, PlayableBinding binding) { bool allowScene = typeof(GameObject).IsAssignableFrom(binding.outputTargetType) || typeof(Component).IsAssignableFrom(binding.outputTargetType); EditorGUI.BeginChangeCheck(); // FocusType.Passive so it never gets focused when pressing tab int controlId = GUIUtility.GetControlID("s_ObjectFieldHash".GetHashCode(), FocusType.Passive, position); var newObject = EditorGUI.DoObjectField(EditorGUI.IndentedRect(position), EditorGUI.IndentedRect(position), controlId, obj, binding.outputTargetType, null, null, allowScene, EditorStyles.objectField); if (EditorGUI.EndChangeCheck()) { BindingUtility.Bind(TimelineEditor.inspectedDirector, binding.sourceObject as TrackAsset, newObject); } }
static void ObjectBindingField(Rect position, Object obj, PlayableBinding binding) { bool allowScene = typeof(GameObject).IsAssignableFrom(binding.outputTargetType) || typeof(Component).IsAssignableFrom(binding.outputTargetType); using (var check = new EditorGUI.ChangeCheckScope()) { // FocusType.Passive so it never gets focused when pressing tab int controlId = GUIUtility.GetControlID("s_ObjectFieldHash".GetHashCode(), FocusType.Passive, position); var newObject = UnityEditorInternals.DoObjectField(EditorGUI.IndentedRect(position), obj, binding.outputTargetType, controlId, allowScene); if (check.changed) { BindingUtility.Bind(TimelineEditor.inspectedDirector, binding.sourceObject as TrackAsset, newObject); } } }