mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Merge branch '3.8' into 4.0-beta
This commit is contained in:
commit
49926fc32a
@ -33,6 +33,7 @@ using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Editor = UnityEditor.Editor;
|
||||
@ -58,7 +59,11 @@ namespace Spine.Unity.Editor {
|
||||
SkeletonData lastSkeletonData;
|
||||
|
||||
void OnEnable () { HandleOnEnablePreview(); }
|
||||
void OnDestroy () { HandleOnDestroyPreview(); }
|
||||
void OnDestroy () {
|
||||
HandleOnDestroyPreview();
|
||||
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
|
||||
EditorApplication.update -= preview.HandleEditorUpdate;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
|
||||
@ -133,6 +138,11 @@ namespace Spine.Unity.Editor {
|
||||
void HandleOnEnablePreview () {
|
||||
if (ThisSkeletonDataAsset != null && ThisSkeletonDataAsset.skeletonJSON == null)
|
||||
return;
|
||||
SpineEditorUtilities.ConfirmInitialization();
|
||||
|
||||
// This handles the case where the managed editor assembly is unloaded before recompilation when code changes.
|
||||
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
|
||||
AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
|
||||
|
||||
preview.Initialize(this.Repaint, ThisSkeletonDataAsset, LastSkinName);
|
||||
preview.PlayPauseAnimation(ThisAnimationName, true);
|
||||
@ -142,6 +152,10 @@ namespace Spine.Unity.Editor {
|
||||
EditorApplication.update += preview.HandleEditorUpdate;
|
||||
}
|
||||
|
||||
private void OnDomainUnload (object sender, EventArgs e) {
|
||||
OnDestroy();
|
||||
}
|
||||
|
||||
private void HandleOnSkinChanged (string skinName) {
|
||||
EditorPrefs.SetString(LastSkinKey, skinName);
|
||||
preview.PlayPauseAnimation(ThisAnimationName, true);
|
||||
|
||||
@ -1158,7 +1158,7 @@ namespace Spine.Unity.Editor {
|
||||
float lineRectWidth = lineRect.width;
|
||||
TrackEntry t = skeletonAnimation.AnimationState.GetCurrent(0);
|
||||
|
||||
if (t != null) {
|
||||
if (t != null && Icons.userEvent != null) { // when changing to play mode, Icons.userEvent will not be reset
|
||||
int loopCount = (int)(t.TrackTime / t.TrackEnd);
|
||||
float currentTime = t.TrackTime - (t.TrackEnd * loopCount);
|
||||
float normalizedTime = currentTime / t.Animation.Duration;
|
||||
@ -1176,14 +1176,15 @@ namespace Spine.Unity.Editor {
|
||||
for (int i = 0; i < currentAnimationEvents.Count; i++) {
|
||||
float eventTime = currentAnimationEventTimes[i];
|
||||
var userEventIcon = Icons.userEvent;
|
||||
float iconX = Mathf.Max(((eventTime / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x);
|
||||
float iconY = barRect.y + userEventIcon.height;
|
||||
var evRect = new Rect(barRect) {
|
||||
x = Mathf.Max(((eventTime / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x),
|
||||
y = barRect.y + userEventIcon.height,
|
||||
x = iconX,
|
||||
y = iconY,
|
||||
width = userEventIcon.width,
|
||||
height = userEventIcon.height
|
||||
};
|
||||
GUI.DrawTexture(evRect, userEventIcon);
|
||||
|
||||
Event ev = Event.current;
|
||||
if (ev.type == EventType.Repaint) {
|
||||
if (evRect.Contains(ev.mousePosition)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user