mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fixed game and scene view updates on skin change for SkeletonRenderer. Closes #1361
This commit is contained in:
parent
c63bc7b88f
commit
b23ef5ef1a
@ -163,6 +163,7 @@ namespace Spine.Unity.Editor {
|
|||||||
override public void OnInspectorGUI () {
|
override public void OnInspectorGUI () {
|
||||||
bool multi = serializedObject.isEditingMultipleObjects;
|
bool multi = serializedObject.isEditingMultipleObjects;
|
||||||
DrawInspectorGUI(multi);
|
DrawInspectorGUI(multi);
|
||||||
|
HandleSkinChange();
|
||||||
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current) ||
|
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current) ||
|
||||||
AreAnyMaskMaterialsMissing()) {
|
AreAnyMaskMaterialsMissing()) {
|
||||||
if (!Application.isPlaying) {
|
if (!Application.isPlaying) {
|
||||||
@ -174,21 +175,6 @@ namespace Spine.Unity.Editor {
|
|||||||
SceneView.RepaintAll();
|
SceneView.RepaintAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Application.isPlaying && Event.current.type == EventType.Layout) {
|
|
||||||
bool mismatchDetected = false;
|
|
||||||
if (multi) {
|
|
||||||
foreach (var o in targets)
|
|
||||||
mismatchDetected |= UpdateIfSkinMismatch((SkeletonRenderer)o);
|
|
||||||
} else {
|
|
||||||
mismatchDetected |= UpdateIfSkinMismatch(target as SkeletonRenderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mismatchDetected) {
|
|
||||||
mismatchDetected = false;
|
|
||||||
SceneView.RepaintAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void DrawInspectorGUI (bool multi) {
|
protected virtual void DrawInspectorGUI (bool multi) {
|
||||||
@ -493,12 +479,26 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool UpdateIfSkinMismatch (SkeletonRenderer skeletonRenderer) {
|
void HandleSkinChange() {
|
||||||
|
if (!Application.isPlaying && Event.current.type == EventType.Layout && !initialSkinName.hasMultipleDifferentValues) {
|
||||||
|
bool mismatchDetected = false;
|
||||||
|
string newSkinName = initialSkinName.stringValue;
|
||||||
|
foreach (var o in targets) {
|
||||||
|
mismatchDetected |= UpdateIfSkinMismatch((SkeletonRenderer)o, newSkinName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mismatchDetected) {
|
||||||
|
mismatchDetected = false;
|
||||||
|
SceneView.RepaintAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool UpdateIfSkinMismatch (SkeletonRenderer skeletonRenderer, string componentSkinName) {
|
||||||
if (!skeletonRenderer.valid) return false;
|
if (!skeletonRenderer.valid) return false;
|
||||||
|
|
||||||
var skin = skeletonRenderer.Skeleton.Skin;
|
var skin = skeletonRenderer.Skeleton.Skin;
|
||||||
string skeletonSkinName = skin != null ? skin.Name : null;
|
string skeletonSkinName = skin != null ? skin.Name : null;
|
||||||
string componentSkinName = skeletonRenderer.initialSkinName;
|
|
||||||
bool defaultCase = skin == null && string.IsNullOrEmpty(componentSkinName);
|
bool defaultCase = skin == null && string.IsNullOrEmpty(componentSkinName);
|
||||||
bool fieldMatchesSkin = defaultCase || string.Equals(componentSkinName, skeletonSkinName, System.StringComparison.Ordinal);
|
bool fieldMatchesSkin = defaultCase || string.Equals(componentSkinName, skeletonSkinName, System.StringComparison.Ordinal);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user