protected override Texture GetIconForItem(TreeViewItem item) { var node = item as CurveTreeViewNode; if (node == null) { return(null); } var type = node.iconType; if (type == null) { return(null); } // track type icon if (typeof(TrackAsset).IsAssignableFrom(type)) { var icon = TrackResourceCache.GetTrackIconForType(type); return(icon == s_TrackDefault ? s_DefaultScriptTexture : icon); } // custom clip icons always use the script texture if (typeof(PlayableAsset).IsAssignableFrom(type)) { return(s_DefaultScriptTexture); } // this will return null for MonoBehaviours without a custom icon. // use the scripting icon instead return(AssetPreview.GetMiniTypeThumbnail(type) ?? s_DefaultScriptTexture); }
internal override void OnHeaderIconGUI(Rect iconRect) { using (new EditorGUI.DisabledScope(IsLocked())) { var bgColor = Color.white; if (!EditorGUIUtility.isProSkin) { bgColor.a = 0.55f; } using (new GUIColorOverride(bgColor)) { GUI.Label(iconRect, Styles.TimelineClipBG); } var fgColor = Color.white; if (m_SelectionInfo != null && m_SelectionInfo.uniqueParentTracks.Count == 1) { fgColor = TrackResourceCache.GetTrackColor(m_SelectionInfo.uniqueParentTracks.First()); } using (new GUIColorOverride(fgColor)) { GUI.Label(iconRect, Styles.TimelineClipFG); } } }
public virtual void OnEnable() { m_IsBuiltInType = target != null && target.GetType().Assembly == typeof(TrackAsset).Assembly; m_Name = serializedObject.FindProperty("m_Name"); m_TrackCurvesWrapper = new TrackCurvesWrapper(target as TrackAsset); m_HeaderIcon = TrackResourceCache.s_DefaultIcon.image; // only worry about the first track. if types are different, a different inspector is used. var track = target as TrackAsset; if (track != null) { var drawer = CustomTimelineEditorCache.GetTrackEditor(track); UnityEngine.Object binding = null; var director = m_Context as PlayableDirector; if (director != null) { binding = director.GetGenericBinding(track); } var options = drawer.GetTrackOptions(track, binding); if (options.icon != null) { m_HeaderIcon = options.icon; } else { m_HeaderIcon = TrackResourceCache.GetTrackIcon(track).image; } } }
/// <summary> /// The color drawn under the clip. By default, the color is the same as the track color. /// </summary> /// <param name="clip">The clip being drawn.</param> /// <returns>Returns the highlight color of the clip being drawn.</returns> public Color GetDefaultHighlightColor(TimelineClip clip) { if (clip == null) { return(Color.white); } return(TrackResourceCache.GetTrackColor(clip.GetParentTrack())); }
public TimelineTrackGUI(TreeViewController tv, TimelineTreeViewGUI w, int id, int depth, TreeViewItem parent, string displayName, TrackAsset sequenceActor) : base(tv, w, id, depth, parent, displayName, sequenceActor, false) { AnimationTrack animationTrack = sequenceActor as AnimationTrack; if (animationTrack != null) { m_InfiniteTrackDrawer = new InfiniteTrackDrawer(new AnimationTrackKeyDataSource(animationTrack)); } else if (sequenceActor.HasAnyAnimatableParameters() && !sequenceActor.clips.Any()) { m_InfiniteTrackDrawer = new InfiniteTrackDrawer(new TrackPropertyCurvesDataSource(sequenceActor)); } UpdateInfiniteClipEditor(w.TimelineWindow); var bindings = track.outputs.ToArray(); m_TrackDrawData.m_HasBinding = bindings.Length > 0; if (m_TrackDrawData.m_HasBinding) { m_TrackDrawData.m_Binding = bindings[0]; } m_TrackDrawData.m_IsSubTrack = IsSubTrack(); m_TrackDrawData.m_AllowsRecording = DoesTrackAllowsRecording(sequenceActor); m_DefaultTrackIcon = TrackResourceCache.GetTrackIcon(track); m_TrackEditor = CustomTimelineEditorCache.GetTrackEditor(sequenceActor); try { m_TrackDrawOptions = m_TrackEditor.GetTrackOptions(track, null); } catch (Exception e) { Debug.LogException(e); m_TrackDrawOptions = CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, null); } m_TrackDrawOptions.errorText = null; // explicitly setting to null for an uninitialized state RebuildGUICacheIfNecessary(); }
public void Initialize() { m_DefaultSkinColors = CreateDefaultSkin(); m_DarkSkinColors = LoadColorSkin(s_DarkSkinPath); m_LightSkinColors = LoadColorSkin(s_LightSkinPath); // add the built in colors (control track uses attribute) TrackResourceCache.ClearTrackColorCache(); TrackResourceCache.SetTrackColor <AnimationTrack>(customSkin.colorAnimation); TrackResourceCache.SetTrackColor <PlayableTrack>(Color.white); TrackResourceCache.SetTrackColor <AudioTrack>(customSkin.colorAudio); TrackResourceCache.SetTrackColor <ActivationTrack>(customSkin.colorActivation); TrackResourceCache.SetTrackColor <GroupTrack>(customSkin.colorGroup); TrackResourceCache.SetTrackColor <ControlTrack>(customSkin.colorControl); // add default icons TrackResourceCache.ClearTrackIconCache(); TrackResourceCache.SetTrackIcon <AnimationTrack>(EditorGUIUtility.IconContent("AnimationClip Icon")); TrackResourceCache.SetTrackIcon <AudioTrack>(EditorGUIUtility.IconContent("AudioSource Icon")); TrackResourceCache.SetTrackIcon <PlayableTrack>(EditorGUIUtility.IconContent("cs Script Icon")); TrackResourceCache.SetTrackIcon <ActivationTrack>(new GUIContent(activation.normal.background)); TrackResourceCache.SetTrackIcon <SignalTrack>(EditorGUIUtility.IconContent("TimelineSignal")); }
public void Initialize() { m_DefaultSkinColors = CreateDefaultSkin(); m_DarkSkinColors = LoadColorSkin(k_DarkSkinPath); m_LightSkinColors = LoadColorSkin(k_LightSkinPath); // add the built in colors (control track uses attribute) TrackResourceCache.ClearTrackColorCache(); TrackResourceCache.SetTrackColor <AnimationTrack>(customSkin.colorAnimation); TrackResourceCache.SetTrackColor <PlayableTrack>(Color.white); TrackResourceCache.SetTrackColor <AudioTrack>(customSkin.colorAudio); TrackResourceCache.SetTrackColor <ActivationTrack>(customSkin.colorActivation); TrackResourceCache.SetTrackColor <GroupTrack>(customSkin.colorGroup); TrackResourceCache.SetTrackColor <ControlTrack>(customSkin.colorControl); // add default icons TrackResourceCache.ClearTrackIconCache(); TrackResourceCache.SetTrackIcon <AnimationTrack>(animationTrackIcon); TrackResourceCache.SetTrackIcon <AudioTrack>(audioTrackIcon); TrackResourceCache.SetTrackIcon <PlayableTrack>(playableTrackIcon); TrackResourceCache.SetTrackIcon <ActivationTrack>(new GUIContent(GetBackgroundImage(activation))); TrackResourceCache.SetTrackIcon <SignalTrack>(signalTrackIcon); }
public static TrackDrawer CreateInstance(TrackAsset trackAsset) { if (trackAsset == null) { return(Activator.CreateInstance <TrackDrawer>()); } TrackDrawer drawer; try { drawer = (TrackDrawer)Activator.CreateInstance(TimelineHelpers.GetCustomDrawer(trackAsset.GetType())); } catch (Exception) { drawer = Activator.CreateInstance <TrackDrawer>(); } drawer.track = trackAsset; drawer.trackColor = TrackResourceCache.GetTrackColor(trackAsset); drawer.icon = TrackResourceCache.GetTrackIcon(trackAsset); return(drawer); }
public override void Draw(Rect headerRect, Rect contentRect, WindowState state) { if (track == null || m_IsRoot) { return; } if (m_MustRecomputeUnions) { RecomputeRectUnions(); } if (depth == 1) { Graphics.DrawBackgroundRect(state, headerRect); } var background = headerRect; background.height = expandedRect.height; var groupColor = TrackResourceCache.GetTrackColor(track); m_TreeViewRect = contentRect; var col = groupColor; var isSelected = SelectionManager.Contains(track); if (isSelected) { col = DirectorStyles.Instance.customSkin.colorSelection; } else if (isDropTarget) { col = DirectorStyles.Instance.customSkin.colorDropTarget; } else { if (m_GroupDepth % 2 == 1) { float h, s, v; Color.RGBToHSV(col, out h, out s, out v); v += 0.06f; col = Color.HSVToRGB(h, s, v); } } if (background.width > 0) { using (new GUIColorOverride(col)) GUI.Box(background, GUIContent.none, m_Styles.groupBackground); } var trackRectBackground = headerRect; trackRectBackground.xMin += background.width; trackRectBackground.width = contentRect.width; trackRectBackground.height = background.height; if (isSelected) { col = state.IsEditingASubTimeline() ? m_Styles.customSkin.colorTrackSubSequenceBackgroundSelected : m_Styles.customSkin.colorTrackBackgroundSelected; } else { col = m_Styles.customSkin.colorGroupTrackBackground; } EditorGUI.DrawRect(trackRectBackground, col); if (!isExpanded && children != null && children.Count > 0) { var collapsedTrackRect = contentRect; foreach (var u in m_Unions) { u.Draw(collapsedTrackRect, state); } } using (new GUIGroupScope(headerRect)) { var groupRect = new Rect(0, 0, headerRect.width, headerRect.height); DrawName(groupRect, isSelected); DrawTrackButtons(groupRect, state); } if (IsTrackRecording(state)) { using (new GUIColorOverride(DirectorStyles.Instance.customSkin.colorTrackBackgroundRecording)) GUI.Label(background, GUIContent.none, m_Styles.displayBackground); } // is this a referenced track? if (m_IsReferencedTrack) { var refRect = contentRect; refRect.x = state.timeAreaRect.xMax - 20.0f; refRect.y += 5.0f; refRect.width = 30.0f; GUI.Label(refRect, DirectorStyles.referenceTrackLabel, EditorStyles.label); } var bgRect = contentRect; if (track as GroupTrack != null || AllChildrenMuted(this)) { bgRect.height = expandedRect.height; } DrawTrackState(contentRect, bgRect, track); }
/// <summary> /// Gets the color information of a track. /// </summary> /// <param name="track"></param> /// <returns>Returns the color for the specified track.</returns> public Color GetTrackColor(TrackAsset track) { return(TrackResourceCache.GetTrackColor(track)); }
public override void Draw(Rect headerRect, Rect contentRect, WindowState state) { if (track == null) { return; } if (m_IsRoot) { return; } if (m_MustRecomputeUnions) { RecomputeRectUnions(); } if (depth == 1) { Graphics.DrawBackgroundRect(state, headerRect); } var background = headerRect; background.height = expandedRect.height; var groupColor = TrackResourceCache.GetTrackColor(track); m_TreeViewRect = contentRect; var col = groupColor; var isSelected = SelectionManager.Contains(track); if (isSelected) { col = DirectorStyles.Instance.customSkin.colorSelection; } else if (isDropTarget) { col = DirectorStyles.Instance.customSkin.colorDropTarget; } else { if (m_GroupDepth % 2 == 1) { float h, s, v; Color.RGBToHSV(col, out h, out s, out v); v += 0.06f; col = Color.HSVToRGB(h, s, v); } } // Draw Rounded Rectangle of the group... using (new GUIColorOverride(col)) GUI.Box(background, GUIContent.none, m_Styles.groupBackground); var trackRectBackground = headerRect; trackRectBackground.xMin += background.width; trackRectBackground.width = contentRect.width; trackRectBackground.height = background.height; if (isSelected) { col = state.IsEditingASubTimeline() ? m_Styles.customSkin.colorTrackSubSequenceBackgroundSelected : m_Styles.customSkin.colorTrackBackgroundSelected; } else { col = m_Styles.customSkin.colorGroupTrackBackground; } EditorGUI.DrawRect(trackRectBackground, col); if (!isExpanded && children != null && children.Count > 0) { var collapsedTrackRect = contentRect; foreach (var u in m_Unions) { u.Draw(collapsedTrackRect, state); } } // Draw the name of the Group... var labelRect = headerRect; labelRect.xMin += 20; var actorName = track != null ? track.name : "missing"; labelRect.width = m_Styles.groupFont.CalcSize(new GUIContent(actorName)).x; labelRect.width = Math.Max(labelRect.width, 50.0f); // if we aren't bound to anything, we show a text field that allows to rename the actor // otherwise we show a ObjectField to allow binding to a go if (track != null && track is GroupTrack) { var textColor = m_Styles.groupFont.normal.textColor; if (isSelected) { textColor = Color.white; } string newName; EditorGUI.BeginChangeCheck(); using (new StyleNormalColorOverride(m_Styles.groupFont, textColor)) { newName = EditorGUI.DelayedTextField(labelRect, GUIContent.none, track.GetInstanceID(), track.name, m_Styles.groupFont); } if (EditorGUI.EndChangeCheck() && !string.IsNullOrEmpty(newName)) { track.name = newName; displayName = track.name; } } DrawTrackButtons(headerRect, state); if (IsTrackRecording(state)) { using (new GUIColorOverride(DirectorStyles.Instance.customSkin.colorTrackBackgroundRecording)) GUI.Label(background, GUIContent.none, m_Styles.displayBackground); } // is this a referenced track? if (m_IsReferencedTrack) { var refRect = contentRect; refRect.x = state.timeAreaRect.xMax - 20.0f; refRect.y += 5.0f; refRect.width = 30.0f; GUI.Label(refRect, DirectorStyles.referenceTrackLabel, EditorStyles.label); } Rect bgRect = contentRect; if (track as GroupTrack != null || AllChildrenMuted(this)) { bgRect.height = expandedRect.height; } DrawTrackState(contentRect, bgRect, track); }