mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 18:56:54 +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 UnityEditor;
|
||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Spine.Unity.Editor {
|
namespace Spine.Unity.Editor {
|
||||||
using Editor = UnityEditor.Editor;
|
using Editor = UnityEditor.Editor;
|
||||||
@ -58,7 +59,11 @@ namespace Spine.Unity.Editor {
|
|||||||
SkeletonData lastSkeletonData;
|
SkeletonData lastSkeletonData;
|
||||||
|
|
||||||
void OnEnable () { HandleOnEnablePreview(); }
|
void OnEnable () { HandleOnEnablePreview(); }
|
||||||
void OnDestroy () { HandleOnDestroyPreview(); }
|
void OnDestroy () {
|
||||||
|
HandleOnDestroyPreview();
|
||||||
|
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
|
||||||
|
EditorApplication.update -= preview.HandleEditorUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnInspectorGUI () {
|
public override void OnInspectorGUI () {
|
||||||
animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
|
animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
|
||||||
@ -133,6 +138,11 @@ namespace Spine.Unity.Editor {
|
|||||||
void HandleOnEnablePreview () {
|
void HandleOnEnablePreview () {
|
||||||
if (ThisSkeletonDataAsset != null && ThisSkeletonDataAsset.skeletonJSON == null)
|
if (ThisSkeletonDataAsset != null && ThisSkeletonDataAsset.skeletonJSON == null)
|
||||||
return;
|
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.Initialize(this.Repaint, ThisSkeletonDataAsset, LastSkinName);
|
||||||
preview.PlayPauseAnimation(ThisAnimationName, true);
|
preview.PlayPauseAnimation(ThisAnimationName, true);
|
||||||
@ -142,6 +152,10 @@ namespace Spine.Unity.Editor {
|
|||||||
EditorApplication.update += preview.HandleEditorUpdate;
|
EditorApplication.update += preview.HandleEditorUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDomainUnload (object sender, EventArgs e) {
|
||||||
|
OnDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
private void HandleOnSkinChanged (string skinName) {
|
private void HandleOnSkinChanged (string skinName) {
|
||||||
EditorPrefs.SetString(LastSkinKey, skinName);
|
EditorPrefs.SetString(LastSkinKey, skinName);
|
||||||
preview.PlayPauseAnimation(ThisAnimationName, true);
|
preview.PlayPauseAnimation(ThisAnimationName, true);
|
||||||
|
|||||||
@ -1158,7 +1158,7 @@ namespace Spine.Unity.Editor {
|
|||||||
float lineRectWidth = lineRect.width;
|
float lineRectWidth = lineRect.width;
|
||||||
TrackEntry t = skeletonAnimation.AnimationState.GetCurrent(0);
|
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);
|
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;
|
||||||
@ -1176,14 +1176,15 @@ namespace Spine.Unity.Editor {
|
|||||||
for (int i = 0; i < currentAnimationEvents.Count; i++) {
|
for (int i = 0; i < currentAnimationEvents.Count; i++) {
|
||||||
float eventTime = currentAnimationEventTimes[i];
|
float eventTime = currentAnimationEventTimes[i];
|
||||||
var userEventIcon = Icons.userEvent;
|
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) {
|
var evRect = new Rect(barRect) {
|
||||||
x = Mathf.Max(((eventTime / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x),
|
x = iconX,
|
||||||
y = barRect.y + userEventIcon.height,
|
y = iconY,
|
||||||
width = userEventIcon.width,
|
width = userEventIcon.width,
|
||||||
height = userEventIcon.height
|
height = userEventIcon.height
|
||||||
};
|
};
|
||||||
GUI.DrawTexture(evRect, userEventIcon);
|
GUI.DrawTexture(evRect, userEventIcon);
|
||||||
|
|
||||||
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)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user