static void DrawLabel(QlistMarker point, MarkerUIStates uiState, MarkerOverlayRegion region) { if (string.IsNullOrEmpty(point.stateName)) { return; } var colorScale = uiState.HasFlag(MarkerUIStates.Selected) ? 1.0f : 0.85f; var textStyle = EditorStyles.whiteMiniLabel; s_Temp.text = point.stateName; var labelRect = region.markerRegion; labelRect.width = textStyle.CalcSize(s_Temp).x + 5; labelRect.x -= labelRect.width; // bring it to the left var shadowRect = Rect.MinMaxRect(labelRect.xMin + 1, labelRect.yMin + 1, labelRect.xMax + 1, labelRect.yMax + 1); var oldColor = GUI.color; // GUI.color = Color.white * colorScale; // GUI.Label(shadowRect, s_Temp, textStyle); GUI.color = Color.black; GUI.Label(labelRect, s_Temp, textStyle); GUI.color = oldColor; }
public override void DrawOverlay(IMarker marker, MarkerUIStates uiState, MarkerOverlayRegion region) { var snapPoint = (QlistMarker)marker; // DrawSnapLine(snapPoint, uiState, region); DrawLabel(snapPoint, uiState, region); }
void MarkerRegionExample(MarkerOverlayRegion region) { #region declare-trackRegion GUI.BeginClip(region.trackRegion, -region.trackRegion.min, Vector2.zero, false); EditorGUI.DrawRect(region.markerRegion, Color.blue); GUI.EndClip(); #endregion }
static void DrawLineOverlay(Color color, MarkerOverlayRegion region) { // Calculate markerRegion's center on the x axis float markerRegionCenterX = region.markerRegion.xMin + (region.markerRegion.width - k_LineOverlayWidth) / 2.0f; // Calculate a rectangle that uses the full timeline region's height Rect overlayLineRect = new Rect(markerRegionCenterX, region.timelineRegion.y, k_LineOverlayWidth, region.timelineRegion.height); Color overlayLineColor = new Color(color.r, color.g, color.b, color.a * 0.5f); EditorGUI.DrawRect(overlayLineRect, overlayLineColor); }
// Draws a vertical line on top of the Timeline window's contents. public override void DrawOverlay(IMarker marker, MarkerUIStates uiState, MarkerOverlayRegion region) { // The `marker argument needs to be cast as the appropriate type, usually the one specified in the `CustomTimelineEditor` attribute AnnotationMarker annotation = marker as AnnotationMarker; if (annotation == null) { return; } if (annotation.showLineOverlay) { DrawLineOverlay(annotation.color, region); } DrawColorOverlay(region, annotation.color, uiState); }
//---------------------------------------------------------------------------------------------------------------------- public override void DrawOverlay(IMarker m, MarkerUIStates uiState, MarkerOverlayRegion region) { FrameMarker marker = m as FrameMarker; if (null == marker) return; SISPlayableFrame playableFrame = marker.GetOwner(); //Check invalid PlayableFrame/ClipData. Perhaps because of unsupported Duplicate operation ? PlayableFrameClipData clipData = playableFrame?.GetOwner(); if (clipData == null) return; PlayableFramePropertyID inspectedPropertyID = clipData.GetInspectedProperty(); switch (inspectedPropertyID) { case PlayableFramePropertyID.USED: { if (playableFrame.IsLocked()) { //At the moment, all locked frames are regarded as inactive if (playableFrame.IsUsed()) { Graphics.DrawTexture(region.markerRegion, EditorTextures.GetInactiveCheckedTexture()); } Rect lockRegion = region.markerRegion; lockRegion.x -= 5; lockRegion.y -= 8; Graphics.DrawTexture(lockRegion, EditorTextures.GetLockTexture()); } else { if (playableFrame.IsUsed()) { Graphics.DrawTexture(region.markerRegion, EditorTextures.GetCheckedTexture()); } } break; } case PlayableFramePropertyID.LOCKED: { if (playableFrame.IsLocked()) { Graphics.DrawTexture(region.markerRegion, EditorTextures.GetLockTexture()); } break; } } }
//---------------------------------------------------------------------------------------------------------------------- public override void DrawOverlay(IMarker m, MarkerUIStates uiState, MarkerOverlayRegion region) { FrameMarker marker = m as FrameMarker; if (null == marker) return; SISPlayableFrame playableFrame = marker.GetOwner(); TimelineClipSISData timelineClipSISData = playableFrame.GetOwner(); PlayableFramePropertyID inspectedPropertyID = timelineClipSISData.GetInspectedProperty(); switch (inspectedPropertyID) { case PlayableFramePropertyID.USED: { if (playableFrame.IsLocked()) { //At the moment, all locked frames are regarded as inactive if (playableFrame.IsUsed()) { Graphics.DrawTexture(region.markerRegion, EditorTextures.GetInactiveCheckedTexture()); } Rect lockRegion = region.markerRegion; lockRegion.x -= 5; lockRegion.y -= 8; Graphics.DrawTexture(lockRegion, EditorTextures.GetLockTexture()); } else { if (playableFrame.IsUsed()) { Graphics.DrawTexture(region.markerRegion, EditorTextures.GetCheckedTexture()); } } break; } case PlayableFramePropertyID.LOCKED: { if (playableFrame.IsLocked()) { Graphics.DrawTexture(region.markerRegion, EditorTextures.GetLockTexture()); } break; } } }
static void DrawColorOverlay(MarkerOverlayRegion region, Color color, MarkerUIStates state) { // Save the Editor's overlay color before changing it Color oldColor = GUI.color; GUI.color = color; if (state.HasFlag(MarkerUIStates.Selected)) { GUI.DrawTexture(region.markerRegion, s_OverlaySelectedTexture); } else if (state.HasFlag(MarkerUIStates.Collapsed)) { GUI.DrawTexture(region.markerRegion, s_OverlayCollapsedTexture); } else if (state.HasFlag(MarkerUIStates.None)) { GUI.DrawTexture(region.markerRegion, s_OverlayTexture); } // Restore the previous Editor's overlay color GUI.color = oldColor; }
// static void DrawSnapLine(QlistMarker snapPoint, MarkerUIStates uiState, MarkerOverlayRegion region) // { // if (snapPoint.snapLine == QlistMarker.SnapLine.None) // return; // var collapsed = uiState.HasFlag(MarkerUIStates.Collapsed); // if (collapsed && snapPoint.snapLine == QlistMarker.SnapLine.NotCollapsed) // return; // float offset = collapsed ? 7: 15; // var color = snapPoint.snapLineColor; // if (uiState.HasFlag(MarkerUIStates.Selected)) // { // color = color * 1.5f; // } // var r = new Rect(region.markerRegion.center.x - 0.5f, // region.markerRegion.min.y + offset, // 1.0f, // region.timelineRegion.height // ); // var oldColor = GUI.color; // GUI.color = color; // GUI.DrawTexture(r, Texture2D.whiteTexture, ScaleMode.StretchToFill); // if (snapPoint.drawHighlight) // { // var previousTime = region.startTime; // foreach (var m in snapPoint.parent.GetMarkers()) // { // if (m.time < snapPoint.time && m is QlistMarker) // previousTime = Math.Max(m.time, previousTime); // } // if (previousTime != snapPoint.time) // { // Rect highlightRect = region.markerRegion; // highlightRect.xMin = ToPixel(region, previousTime); // highlightRect.xMax = region.markerRegion.center.x; // highlightRect.height = 2; // GUI.DrawTexture(highlightRect, Texture2D.whiteTexture, ScaleMode.StretchToFill, true); // } // } // GUI.color = oldColor; // } static float ToPixel(MarkerOverlayRegion region, double time) { var p = (time - region.startTime) / (region.endTime - region.startTime); return(region.timelineRegion.x + region.timelineRegion.width * (float)p); }