Merge branch '3.7-beta' into 3.7-beta-cpp

This commit is contained in:
badlogic 2018-06-13 14:40:45 +02:00
commit 59aa3a8780

View File

@ -682,6 +682,7 @@ namespace Spine.Unity.Editor {
List<Spine.Event> currentAnimationEvents = new List<Spine.Event>(); List<Spine.Event> currentAnimationEvents = new List<Spine.Event>();
List<float> currentAnimationEventTimes = new List<float>(); List<float> currentAnimationEventTimes = new List<float>();
List<SpineEventTooltip> currentAnimationEventTooltips = new List<SpineEventTooltip>();
public bool IsValid { get { return skeletonAnimation != null && skeletonAnimation.valid; } } public bool IsValid { get { return skeletonAnimation != null && skeletonAnimation.valid; } }
@ -1071,7 +1072,7 @@ namespace Spine.Unity.Editor {
int loopCount = (int)(t.TrackTime / t.TrackEnd); int loopCount = (int)(t.TrackTime / t.TrackEnd);
float currentTime = t.TrackTime - (t.TrackEnd * loopCount); float currentTime = t.TrackTime - (t.TrackEnd * loopCount);
float normalizedTime = currentTime / t.Animation.Duration; float normalizedTime = currentTime / t.Animation.Duration;
float wrappedTime = normalizedTime % 1; float wrappedTime = normalizedTime % 1f;
lineRect.x = barRect.x + (lineRectWidth * wrappedTime) - 0.5f; lineRect.x = barRect.x + (lineRectWidth * wrappedTime) - 0.5f;
lineRect.width = 2; lineRect.width = 2;
@ -1080,11 +1081,13 @@ namespace Spine.Unity.Editor {
GUI.DrawTexture(lineRect, EditorGUIUtility.whiteTexture); GUI.DrawTexture(lineRect, EditorGUIUtility.whiteTexture);
GUI.color = Color.white; GUI.color = Color.white;
currentAnimationEventTooltips = currentAnimationEventTooltips ?? new List<SpineEventTooltip>();
currentAnimationEventTooltips.Clear();
for (int i = 0; i < currentAnimationEvents.Count; i++) { for (int i = 0; i < currentAnimationEvents.Count; i++) {
float fr = currentAnimationEventTimes[i]; float eventTime = currentAnimationEventTimes[i];
var userEventIcon = Icons.userEvent; var userEventIcon = Icons.userEvent;
var evRect = new Rect(barRect) { var evRect = new Rect(barRect) {
x = Mathf.Clamp(((fr / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x, float.MaxValue), x = Mathf.Max(((eventTime / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x),
y = barRect.y + userEventIcon.height, y = barRect.y + userEventIcon.height,
width = userEventIcon.width, width = userEventIcon.width,
height = userEventIcon.height height = userEventIcon.height
@ -1094,16 +1097,29 @@ namespace Spine.Unity.Editor {
Event ev = Event.current; Event ev = Event.current;
if (ev.type == EventType.Repaint) { if (ev.type == EventType.Repaint) {
if (evRect.Contains(ev.mousePosition)) { if (evRect.Contains(ev.mousePosition)) {
GUIStyle tooltipStyle = EditorStyles.helpBox; string eventName = currentAnimationEvents[i].Data.Name;
Rect tooltipRect = new Rect(evRect); Rect tooltipRect = new Rect(evRect) {
tooltipRect.width = tooltipStyle.CalcSize(new GUIContent(currentAnimationEvents[i].Data.Name)).x; width = EditorStyles.helpBox.CalcSize(new GUIContent(eventName)).x
};
tooltipRect.y -= 4; tooltipRect.y -= 4;
tooltipRect.y -= tooltipRect.height * currentAnimationEventTooltips.Count; // Avoid several overlapping tooltips.
tooltipRect.x += 4; tooltipRect.x += 4;
GUI.Label(tooltipRect, currentAnimationEvents[i].Data.Name, tooltipStyle);
GUI.tooltip = currentAnimationEvents[i].Data.Name; // Handle tooltip overflowing to the right.
float rightEdgeOverflow = (tooltipRect.x + tooltipRect.width) - (barRect.x + barRect.width);
if (rightEdgeOverflow > 0)
tooltipRect.x -= rightEdgeOverflow;
currentAnimationEventTooltips.Add(new SpineEventTooltip { rect = tooltipRect, text = eventName });
} }
} }
} }
// Draw tooltips.
for (int i = 0; i < currentAnimationEventTooltips.Count; i++) {
GUI.Label(currentAnimationEventTooltips[i].rect, currentAnimationEventTooltips[i].text, EditorStyles.helpBox);
GUI.tooltip = currentAnimationEventTooltips[i].text;
}
} }
} }
@ -1130,7 +1146,11 @@ namespace Spine.Unity.Editor {
previewGameObject = null; previewGameObject = null;
} }
} }
internal struct SpineEventTooltip {
public Rect rect;
public string text;
}
} }
} }