mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[unity] Fix SkeletonRenderSeparator edit mode refresh.
This commit is contained in:
parent
819bb4cf0c
commit
35a7a7be76
@ -63,6 +63,27 @@ namespace Spine.Unity.Editor {
|
||||
sortingProperties = new SpineInspectorUtility.SerializedSortingProperties(renderer);
|
||||
}
|
||||
|
||||
public static void ReapplySeparatorSlotNames (SkeletonRenderer skeletonRenderer) {
|
||||
if (!skeletonRenderer.valid) return;
|
||||
|
||||
var separatorSlots = skeletonRenderer.separatorSlots;
|
||||
var separatorSlotNames = skeletonRenderer.separatorSlotNames;
|
||||
var skeleton = skeletonRenderer.skeleton;
|
||||
|
||||
separatorSlots.Clear();
|
||||
for (int i = 0, n = separatorSlotNames.Length; i < n; i++) {
|
||||
var slot = skeleton.FindSlot(separatorSlotNames[i]);
|
||||
if (slot != null) {
|
||||
separatorSlots.Add(slot);
|
||||
//Debug.Log(slot + " added as separator.");
|
||||
} else {
|
||||
Debug.LogWarning(separatorSlotNames[i] + " is not a slot in " + skeletonRenderer.skeletonDataAsset.skeletonJSON.name);
|
||||
}
|
||||
}
|
||||
|
||||
//Debug.Log("Reapplied Separator Slot Names. Count is now: " + separatorSlots.Count);
|
||||
}
|
||||
|
||||
protected virtual void DrawInspectorGUI () {
|
||||
// JOHN: todo: support multiediting.
|
||||
SkeletonRenderer component = (SkeletonRenderer)target;
|
||||
|
||||
@ -48,6 +48,7 @@ namespace Spine.Unity.Modules {
|
||||
SerializedObject skeletonRendererSerializedObject;
|
||||
SerializedProperty separatorNamesProp;
|
||||
static bool skeletonRendererExpanded = true;
|
||||
bool slotsReapplyRequired = false;
|
||||
|
||||
void OnEnable () {
|
||||
if (component == null)
|
||||
@ -133,9 +134,15 @@ namespace Spine.Unity.Modules {
|
||||
EditorGUILayout.HelpBox("Separators are empty. Change the size to 1 and choose a slot if you want the render to be separated.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
skeletonRendererSerializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (!Application.isPlaying)
|
||||
slotsReapplyRequired = true;
|
||||
}
|
||||
|
||||
|
||||
totalParts = separatorCount + 1;
|
||||
var counterStyle = skeletonRendererExpanded ? EditorStyles.label : EditorStyles.miniLabel;
|
||||
EditorGUILayout.LabelField(string.Format("{0}: separates into {1}.", SpineInspectorUtility.Pluralize(separatorCount, "separator", "separators"), SpineInspectorUtility.Pluralize(totalParts, "part", "parts") ), counterStyle);
|
||||
@ -197,6 +204,13 @@ namespace Spine.Unity.Modules {
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (slotsReapplyRequired && UnityEngine.Event.current.type == EventType.Repaint) {
|
||||
SkeletonRendererInspector.ReapplySeparatorSlotNames(component.SkeletonRenderer);
|
||||
component.SkeletonRenderer.LateUpdate();
|
||||
SceneView.RepaintAll();
|
||||
slotsReapplyRequired = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPartsRenderer (int count) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user