mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 23:05:01 +08:00
[unity] Fixed game and scene view updates on skin change for SkeletonRenderer. Closes #1361
This commit is contained in:
parent
9f0da2a986
commit
361b8f8965
@ -163,6 +163,7 @@ namespace Spine.Unity.Editor {
|
||||
override public void OnInspectorGUI () {
|
||||
bool multi = serializedObject.isEditingMultipleObjects;
|
||||
DrawInspectorGUI(multi);
|
||||
HandleSkinChange();
|
||||
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current) ||
|
||||
AreAnyMaskMaterialsMissing()) {
|
||||
if (!Application.isPlaying) {
|
||||
@ -174,21 +175,6 @@ namespace Spine.Unity.Editor {
|
||||
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) {
|
||||
@ -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;
|
||||
|
||||
var skin = skeletonRenderer.Skeleton.Skin;
|
||||
string skeletonSkinName = skin != null ? skin.Name : null;
|
||||
string componentSkinName = skeletonRenderer.initialSkinName;
|
||||
bool defaultCase = skin == null && string.IsNullOrEmpty(componentSkinName);
|
||||
bool fieldMatchesSkin = defaultCase || string.Equals(componentSkinName, skeletonSkinName, System.StringComparison.Ordinal);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user