mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-14 02:58:44 +08:00
[unity] Don't process icons in play mode.
This commit is contained in:
parent
2567339fa6
commit
7f367dd496
@ -228,12 +228,10 @@ namespace Spine.Unity.Editor {
|
||||
EditorApplication.hierarchyWindowItemOnGUI += HierarchyDragAndDrop;
|
||||
|
||||
// Hierarchy Icons
|
||||
EditorApplication.hierarchyWindowChanged -= HierarchyIconsOnChanged;
|
||||
EditorApplication.hierarchyWindowChanged += HierarchyIconsOnChanged;
|
||||
EditorApplication.hierarchyWindowItemOnGUI -= HierarchyIconsOnGUI;
|
||||
EditorApplication.hierarchyWindowItemOnGUI += HierarchyIconsOnGUI;
|
||||
EditorApplication.playmodeStateChanged -= HierarchyIconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playmodeStateChanged += HierarchyIconsOnPlaymodeStateChanged;
|
||||
HierarchyIconsOnPlaymodeStateChanged();
|
||||
|
||||
HierarchyIconsOnChanged();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@ -496,58 +494,68 @@ namespace Spine.Unity.Editor {
|
||||
#endregion
|
||||
|
||||
#region Hierarchy
|
||||
static void HierarchyIconsOnChanged () {
|
||||
if (showHierarchyIcons) {
|
||||
skeletonRendererTable.Clear();
|
||||
skeletonUtilityBoneTable.Clear();
|
||||
boundingBoxFollowerTable.Clear();
|
||||
static void HierarchyIconsOnPlaymodeStateChanged () {
|
||||
skeletonRendererTable.Clear();
|
||||
skeletonUtilityBoneTable.Clear();
|
||||
boundingBoxFollowerTable.Clear();
|
||||
|
||||
SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
|
||||
foreach (SkeletonRenderer r in arr)
|
||||
skeletonRendererTable.Add(r.gameObject.GetInstanceID(), r.gameObject);
|
||||
EditorApplication.hierarchyWindowChanged -= HierarchyIconsOnChanged;
|
||||
EditorApplication.hierarchyWindowItemOnGUI -= HierarchyIconsOnGUI;
|
||||
|
||||
SkeletonUtilityBone[] boneArr = Object.FindObjectsOfType<SkeletonUtilityBone>();
|
||||
foreach (SkeletonUtilityBone b in boneArr)
|
||||
skeletonUtilityBoneTable.Add(b.gameObject.GetInstanceID(), b);
|
||||
|
||||
BoundingBoxFollower[] bbfArr = Object.FindObjectsOfType<BoundingBoxFollower>();
|
||||
foreach (BoundingBoxFollower bbf in bbfArr)
|
||||
boundingBoxFollowerTable.Add(bbf.gameObject.GetInstanceID(), bbf);
|
||||
if (!Application.isPlaying && showHierarchyIcons) {
|
||||
EditorApplication.hierarchyWindowChanged += HierarchyIconsOnChanged;
|
||||
EditorApplication.hierarchyWindowItemOnGUI += HierarchyIconsOnGUI;
|
||||
HierarchyIconsOnChanged();
|
||||
}
|
||||
}
|
||||
|
||||
static void HierarchyIconsOnGUI (int instanceId, Rect selectionRect) {
|
||||
if (showHierarchyIcons) {
|
||||
Rect r = new Rect(selectionRect);
|
||||
if (skeletonRendererTable.ContainsKey(instanceId)) {
|
||||
r.x = r.width - 15;
|
||||
r.width = 15;
|
||||
GUI.Label(r, Icons.spine);
|
||||
} else if (skeletonUtilityBoneTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (skeletonUtilityBoneTable[instanceId] != null) {
|
||||
if (skeletonUtilityBoneTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow)
|
||||
GUI.DrawTexture(r, Icons.bone);
|
||||
else
|
||||
GUI.DrawTexture(r, Icons.poseBones);
|
||||
}
|
||||
} else if (boundingBoxFollowerTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (boundingBoxFollowerTable[instanceId] != null) {
|
||||
if (boundingBoxFollowerTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
GUI.DrawTexture(r, Icons.boundingBox);
|
||||
}
|
||||
}
|
||||
static void HierarchyIconsOnChanged () {
|
||||
skeletonRendererTable.Clear();
|
||||
skeletonUtilityBoneTable.Clear();
|
||||
boundingBoxFollowerTable.Clear();
|
||||
|
||||
SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
|
||||
foreach (SkeletonRenderer r in arr)
|
||||
skeletonRendererTable.Add(r.gameObject.GetInstanceID(), r.gameObject);
|
||||
|
||||
SkeletonUtilityBone[] boneArr = Object.FindObjectsOfType<SkeletonUtilityBone>();
|
||||
foreach (SkeletonUtilityBone b in boneArr)
|
||||
skeletonUtilityBoneTable.Add(b.gameObject.GetInstanceID(), b);
|
||||
|
||||
BoundingBoxFollower[] bbfArr = Object.FindObjectsOfType<BoundingBoxFollower>();
|
||||
foreach (BoundingBoxFollower bbf in bbfArr)
|
||||
boundingBoxFollowerTable.Add(bbf.gameObject.GetInstanceID(), bbf);
|
||||
}
|
||||
|
||||
static void HierarchyIconsOnGUI (int instanceId, Rect selectionRect) {
|
||||
Rect r = new Rect(selectionRect);
|
||||
if (skeletonRendererTable.ContainsKey(instanceId)) {
|
||||
r.x = r.width - 15;
|
||||
r.width = 15;
|
||||
GUI.Label(r, Icons.spine);
|
||||
} else if (skeletonUtilityBoneTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (skeletonUtilityBoneTable[instanceId] != null) {
|
||||
if (skeletonUtilityBoneTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow)
|
||||
GUI.DrawTexture(r, Icons.bone);
|
||||
else
|
||||
GUI.DrawTexture(r, Icons.poseBones);
|
||||
}
|
||||
} else if (boundingBoxFollowerTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (boundingBoxFollowerTable[instanceId] != null) {
|
||||
if (boundingBoxFollowerTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
GUI.DrawTexture(r, Icons.boundingBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user