mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch 'master' of https://github.com/esotericsoftware/spine-runtimes
This commit is contained in:
commit
6d041c8229
@ -6,7 +6,6 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
@ -14,8 +13,6 @@ namespace Spine.Unity.Editor {
|
|||||||
[CustomEditor(typeof(SkeletonUtilityBone)), CanEditMultipleObjects]
|
[CustomEditor(typeof(SkeletonUtilityBone)), CanEditMultipleObjects]
|
||||||
public class SkeletonUtilityBoneInspector : UnityEditor.Editor {
|
public class SkeletonUtilityBoneInspector : UnityEditor.Editor {
|
||||||
SerializedProperty mode, boneName, zPosition, position, rotation, scale, overrideAlpha, parentReference;
|
SerializedProperty mode, boneName, zPosition, position, rotation, scale, overrideAlpha, parentReference;
|
||||||
// MITCH
|
|
||||||
// SerializedProperty flip, flipX;
|
|
||||||
|
|
||||||
//multi selected flags
|
//multi selected flags
|
||||||
bool containsFollows, containsOverrides, multiObject;
|
bool containsFollows, containsOverrides, multiObject;
|
||||||
@ -38,15 +35,10 @@ namespace Spine.Unity.Editor {
|
|||||||
overrideAlpha = this.serializedObject.FindProperty("overrideAlpha");
|
overrideAlpha = this.serializedObject.FindProperty("overrideAlpha");
|
||||||
parentReference = this.serializedObject.FindProperty("parentReference");
|
parentReference = this.serializedObject.FindProperty("parentReference");
|
||||||
|
|
||||||
// MITCH
|
|
||||||
// flip = this.serializedObject.FindProperty("flip");
|
|
||||||
// flipX = this.serializedObject.FindProperty("flipX");
|
|
||||||
|
|
||||||
EvaluateFlags();
|
EvaluateFlags();
|
||||||
|
|
||||||
if (utilityBone.valid == false && skeletonUtility != null && skeletonUtility.skeletonRenderer != null) {
|
if (utilityBone.valid == false && skeletonUtility != null && skeletonUtility.skeletonRenderer != null)
|
||||||
skeletonUtility.skeletonRenderer.Initialize(false);
|
skeletonUtility.skeletonRenderer.Initialize(false);
|
||||||
}
|
|
||||||
|
|
||||||
canCreateHingeChain = CanCreateHingeChain();
|
canCreateHingeChain = CanCreateHingeChain();
|
||||||
|
|
||||||
@ -68,16 +60,13 @@ namespace Spine.Unity.Editor {
|
|||||||
for(int i = 0; i < slotCount; i++){
|
for(int i = 0; i < slotCount; i++){
|
||||||
Slot slot = skeletonUtility.skeletonRenderer.skeleton.Slots.Items[i];
|
Slot slot = skeletonUtility.skeletonRenderer.skeleton.Slots.Items[i];
|
||||||
if (slot.Bone == utilityBone.bone) {
|
if (slot.Bone == utilityBone.bone) {
|
||||||
List<Attachment> attachments = new List<Attachment>();
|
var slotAttachments = new List<Attachment>();
|
||||||
|
skin.FindAttachmentsForSlot(skeleton.FindSlotIndex(slot.Data.Name), slotAttachments);
|
||||||
|
var boundingBoxes = new List<BoundingBoxAttachment>();
|
||||||
skin.FindAttachmentsForSlot(skeleton.FindSlotIndex(slot.Data.Name), attachments);
|
foreach (var att in slotAttachments) {
|
||||||
|
var boundingBoxAttachment = att as BoundingBoxAttachment;
|
||||||
List<BoundingBoxAttachment> boundingBoxes = new List<BoundingBoxAttachment>();
|
if (boundingBoxAttachment != null)
|
||||||
foreach (var att in attachments) {
|
boundingBoxes.Add(boundingBoxAttachment);
|
||||||
if (att is BoundingBoxAttachment) {
|
|
||||||
boundingBoxes.Add((BoundingBoxAttachment)att);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boundingBoxes.Count > 0) {
|
if (boundingBoxes.Count > 0) {
|
||||||
@ -98,15 +87,13 @@ namespace Spine.Unity.Editor {
|
|||||||
} else {
|
} else {
|
||||||
int boneCount = 0;
|
int boneCount = 0;
|
||||||
foreach (Object o in Selection.objects) {
|
foreach (Object o in Selection.objects) {
|
||||||
if (o is GameObject) {
|
var go = o as GameObject;
|
||||||
GameObject go = (GameObject)o;
|
if (go != null) {
|
||||||
SkeletonUtilityBone sub = go.GetComponent<SkeletonUtilityBone>();
|
SkeletonUtilityBone sub = go.GetComponent<SkeletonUtilityBone>();
|
||||||
if (sub != null) {
|
if (sub != null) {
|
||||||
boneCount++;
|
boneCount++;
|
||||||
if (sub.mode == SkeletonUtilityBone.Mode.Follow)
|
containsFollows |= (sub.mode == SkeletonUtilityBone.Mode.Follow);
|
||||||
containsFollows = true;
|
containsOverrides |= (sub.mode == SkeletonUtilityBone.Mode.Override);
|
||||||
if (sub.mode == SkeletonUtilityBone.Mode.Override)
|
|
||||||
containsOverrides = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,130 +113,94 @@ namespace Spine.Unity.Editor {
|
|||||||
containsFollows = mode.enumValueIndex == 0;
|
containsFollows = mode.enumValueIndex == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(multiObject);
|
using (new EditorGUI.DisabledGroupScope(multiObject)) {
|
||||||
{
|
|
||||||
string str = boneName.stringValue;
|
string str = boneName.stringValue;
|
||||||
if (str == "")
|
if (str == "")
|
||||||
str = "<None>";
|
str = "<None>";
|
||||||
if (multiObject)
|
if (multiObject)
|
||||||
str = "<Multiple>";
|
str = "<Multiple>";
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
using (new GUILayout.HorizontalScope()) {
|
||||||
EditorGUILayout.PrefixLabel("Bone");
|
EditorGUILayout.PrefixLabel("Bone");
|
||||||
|
if (GUILayout.Button(str, EditorStyles.popup)) {
|
||||||
if (GUILayout.Button(str, EditorStyles.popup)) {
|
BoneSelectorContextMenu(str, ((SkeletonUtilityBone)target).skeletonUtility.skeletonRenderer.skeleton.Bones, "<None>", TargetBoneSelected);
|
||||||
BoneSelectorContextMenu(str, ((SkeletonUtilityBone)target).skeletonUtility.skeletonRenderer.skeleton.Bones, "<None>", TargetBoneSelected);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
}
|
||||||
EditorGUI.EndDisabledGroup();
|
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(zPosition);
|
EditorGUILayout.PropertyField(zPosition);
|
||||||
EditorGUILayout.PropertyField(position);
|
EditorGUILayout.PropertyField(position);
|
||||||
EditorGUILayout.PropertyField(rotation);
|
EditorGUILayout.PropertyField(rotation);
|
||||||
EditorGUILayout.PropertyField(scale);
|
EditorGUILayout.PropertyField(scale);
|
||||||
// MITCH
|
|
||||||
// EditorGUILayout.PropertyField(flip);
|
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(containsFollows);
|
using (new EditorGUI.DisabledGroupScope(containsFollows)) {
|
||||||
{
|
|
||||||
EditorGUILayout.PropertyField(overrideAlpha);
|
EditorGUILayout.PropertyField(overrideAlpha);
|
||||||
EditorGUILayout.PropertyField(parentReference);
|
EditorGUILayout.PropertyField(parentReference);
|
||||||
|
|
||||||
// MITCH
|
|
||||||
// EditorGUI.BeginDisabledGroup(multiObject || !flip.boolValue);
|
|
||||||
// {
|
|
||||||
// EditorGUI.BeginChangeCheck();
|
|
||||||
// EditorGUILayout.PropertyField(flipX);
|
|
||||||
// if (EditorGUI.EndChangeCheck()) {
|
|
||||||
// FlipX(flipX.boolValue);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// EditorGUI.EndDisabledGroup();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
EditorGUI.EndDisabledGroup();
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
using (new GUILayout.HorizontalScope()) {
|
||||||
{
|
using (new EditorGUI.DisabledGroupScope(multiObject || !utilityBone.valid || utilityBone.bone == null || utilityBone.bone.Children.Count == 0)) {
|
||||||
EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || utilityBone.bone == null || utilityBone.bone.Children.Count == 0);
|
|
||||||
{
|
|
||||||
if (GUILayout.Button(new GUIContent("Add Child", SpineEditorUtilities.Icons.bone), GUILayout.Width(150), GUILayout.Height(24)))
|
if (GUILayout.Button(new GUIContent("Add Child", SpineEditorUtilities.Icons.bone), GUILayout.Width(150), GUILayout.Height(24)))
|
||||||
BoneSelectorContextMenu("", utilityBone.bone.Children, "<Recursively>", SpawnChildBoneSelected);
|
BoneSelectorContextMenu("", utilityBone.bone.Children, "<Recursively>", SpawnChildBoneSelected);
|
||||||
}
|
}
|
||||||
EditorGUI.EndDisabledGroup();
|
using (new EditorGUI.DisabledGroupScope(multiObject || !utilityBone.valid || utilityBone.bone == null || containsOverrides)) {
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || utilityBone.bone == null || containsOverrides);
|
|
||||||
{
|
|
||||||
if (GUILayout.Button(new GUIContent("Add Override", SpineEditorUtilities.Icons.poseBones), GUILayout.Width(150), GUILayout.Height(24)))
|
if (GUILayout.Button(new GUIContent("Add Override", SpineEditorUtilities.Icons.poseBones), GUILayout.Width(150), GUILayout.Height(24)))
|
||||||
SpawnOverride();
|
SpawnOverride();
|
||||||
}
|
}
|
||||||
EditorGUI.EndDisabledGroup();
|
using (new EditorGUI.DisabledGroupScope(multiObject || !utilityBone.valid || !canCreateHingeChain)) {
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || !canCreateHingeChain);
|
|
||||||
{
|
|
||||||
if (GUILayout.Button(new GUIContent("Create Hinge Chain", SpineEditorUtilities.Icons.hingeChain), GUILayout.Width(150), GUILayout.Height(24)))
|
if (GUILayout.Button(new GUIContent("Create Hinge Chain", SpineEditorUtilities.Icons.hingeChain), GUILayout.Width(150), GUILayout.Height(24)))
|
||||||
CreateHingeChain();
|
CreateHingeChain();
|
||||||
}
|
}
|
||||||
EditorGUI.EndDisabledGroup();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(multiObject || boundingBoxTable.Count == 0);
|
using (new EditorGUI.DisabledGroupScope(multiObject || boundingBoxTable.Count == 0)) {
|
||||||
EditorGUILayout.LabelField(new GUIContent("Bounding Boxes", SpineEditorUtilities.Icons.boundingBox), EditorStyles.boldLabel);
|
EditorGUILayout.LabelField(new GUIContent("Bounding Boxes", SpineEditorUtilities.Icons.boundingBox), EditorStyles.boldLabel);
|
||||||
|
|
||||||
|
foreach(var entry in boundingBoxTable){
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
EditorGUILayout.LabelField(entry.Key.Data.Name);
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
{
|
||||||
|
foreach (var box in entry.Value) {
|
||||||
|
using (new GUILayout.HorizontalScope()) {
|
||||||
|
GUILayout.Space(30);
|
||||||
|
if (GUILayout.Button(box.Name, GUILayout.Width(200))) {
|
||||||
|
var child = utilityBone.transform.FindChild("[BoundingBox]" + box.Name);
|
||||||
|
if (child != null) {
|
||||||
|
var originalCollider = child.GetComponent<PolygonCollider2D>();
|
||||||
|
var updatedCollider = SkeletonUtility.AddBoundingBoxAsComponent(box, child.gameObject, originalCollider.isTrigger);
|
||||||
|
originalCollider.points = updatedCollider.points;
|
||||||
|
if (EditorApplication.isPlaying)
|
||||||
|
Destroy(updatedCollider);
|
||||||
|
else
|
||||||
|
DestroyImmediate(updatedCollider);
|
||||||
|
} else {
|
||||||
|
utilityBone.AddBoundingBox(currentSkinName, entry.Key.Data.Name, box.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach(var entry in boundingBoxTable){
|
|
||||||
EditorGUI.indentLevel++;
|
|
||||||
EditorGUILayout.LabelField(entry.Key.Data.Name);
|
|
||||||
EditorGUI.indentLevel++;
|
|
||||||
foreach (var box in entry.Value) {
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
GUILayout.Space(30);
|
|
||||||
if (GUILayout.Button(box.Name, GUILayout.Width(200))) {
|
|
||||||
var child = utilityBone.transform.FindChild("[BoundingBox]" + box.Name);
|
|
||||||
if (child != null) {
|
|
||||||
var originalCollider = child.GetComponent<PolygonCollider2D>();
|
|
||||||
var updatedCollider = SkeletonUtility.AddBoundingBoxAsComponent(box, child.gameObject, originalCollider.isTrigger);
|
|
||||||
originalCollider.points = updatedCollider.points;
|
|
||||||
if (EditorApplication.isPlaying)
|
|
||||||
Destroy(updatedCollider);
|
|
||||||
else
|
|
||||||
DestroyImmediate(updatedCollider);
|
|
||||||
} else {
|
|
||||||
utilityBone.AddBoundingBox(currentSkinName, entry.Key.Data.Name, box.Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
EditorGUI.indentLevel--;
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUI.EndDisabledGroup();
|
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MITCH
|
static void BoneSelectorContextMenu (string current, ExposedList<Bone> bones, string topValue, GenericMenu.MenuFunction2 callback) {
|
||||||
// void FlipX (bool state) {
|
|
||||||
// utilityBone.FlipX(state);
|
|
||||||
// if (Application.isPlaying == false) {
|
|
||||||
// skeletonUtility.skeletonAnimation.LateUpdate();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
void BoneSelectorContextMenu (string current, ExposedList<Bone> bones, string topValue, GenericMenu.MenuFunction2 callback) {
|
|
||||||
GenericMenu menu = new GenericMenu();
|
GenericMenu menu = new GenericMenu();
|
||||||
|
|
||||||
if (topValue != "")
|
if (topValue != "")
|
||||||
menu.AddItem(new GUIContent(topValue), current == topValue, callback, null);
|
menu.AddItem(new GUIContent(topValue), current == topValue, callback, null);
|
||||||
|
|
||||||
for (int i = 0; i < bones.Count; i++) {
|
for (int i = 0; i < bones.Count; i++)
|
||||||
menu.AddItem(new GUIContent(bones.Items[i].Data.Name), bones.Items[i].Data.Name == current, callback, bones.Items[i]);
|
menu.AddItem(new GUIContent(bones.Items[i].Data.Name), bones.Items[i].Data.Name == current, callback, bones.Items[i]);
|
||||||
}
|
|
||||||
|
|
||||||
menu.ShowAsContext();
|
menu.ShowAsContext();
|
||||||
|
|
||||||
@ -329,10 +280,10 @@ namespace Spine.Unity.Editor {
|
|||||||
joint.axis = Vector3.forward;
|
joint.axis = Vector3.forward;
|
||||||
joint.connectedBody = utilBone.transform.parent.GetComponent<Rigidbody>();
|
joint.connectedBody = utilBone.transform.parent.GetComponent<Rigidbody>();
|
||||||
joint.useLimits = true;
|
joint.useLimits = true;
|
||||||
JointLimits limits = new JointLimits();
|
joint.limits = new JointLimits {
|
||||||
limits.min = -20;
|
min = -20,
|
||||||
limits.max = 20;
|
max = 20
|
||||||
joint.limits = limits;
|
};
|
||||||
utilBone.GetComponent<Rigidbody>().mass = utilBone.transform.parent.GetComponent<Rigidbody>().mass * 0.75f;
|
utilBone.GetComponent<Rigidbody>().mass = utilBone.transform.parent.GetComponent<Rigidbody>().mass * 0.75f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,8 +296,8 @@ namespace Spine.Unity.Editor {
|
|||||||
} else {
|
} else {
|
||||||
float length = utilBone.bone.Data.Length;
|
float length = utilBone.bone.Data.Length;
|
||||||
BoxCollider box = utilBone.gameObject.AddComponent<BoxCollider>();
|
BoxCollider box = utilBone.gameObject.AddComponent<BoxCollider>();
|
||||||
box.size = new Vector3(length, length / 3, 0.2f);
|
box.size = new Vector3(length, length / 3f, 0.2f);
|
||||||
box.center = new Vector3(length / 2, 0, 0);
|
box.center = new Vector3(length / 2f, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user