[unity] Some cleanup and documentation.

This commit is contained in:
pharan 2016-08-29 17:17:56 +08:00
parent ee324f4bde
commit e0ee7ce4f5
4 changed files with 33 additions and 10 deletions

View File

@ -64,8 +64,8 @@ namespace Spine.Unity.Editor {
if (skeletonRenderer.objectReferenceValue == null) { if (skeletonRenderer.objectReferenceValue == null) {
SkeletonRenderer parentRenderer = BoneFollowerInspector.GetInParent<SkeletonRenderer>(targetBoneFollower.transform); SkeletonRenderer parentRenderer = BoneFollowerInspector.GetInParent<SkeletonRenderer>(targetBoneFollower.transform);
if (parentRenderer != null && parentRenderer.gameObject != targetBoneFollower.gameObject) { if (parentRenderer != null && parentRenderer.gameObject != targetBoneFollower.gameObject) {
Debug.Log("Inspector automatically assigned BoneFollower.SkeletonRenderer");
skeletonRenderer.objectReferenceValue = parentRenderer; skeletonRenderer.objectReferenceValue = parentRenderer;
Debug.Log("Inspector automatically assigned BoneFollower.SkeletonRenderer");
} }
} }

View File

@ -45,16 +45,30 @@ namespace Spine.Unity {
public Spine.AnimationState state; public Spine.AnimationState state;
public Spine.AnimationState AnimationState { get { return this.state; } } public Spine.AnimationState AnimationState { get { return this.state; } }
/// <summary>
/// Occurs after the animations are applied and before world space values are resolved.
/// Use this callback when you want to set bone local values.
/// </summary>
public event UpdateBonesDelegate UpdateLocal { public event UpdateBonesDelegate UpdateLocal {
add { _UpdateLocal += value; } add { _UpdateLocal += value; }
remove { _UpdateLocal -= value; } remove { _UpdateLocal -= value; }
} }
/// <summary>
/// Occurs after the Skeleton's bone world space values are resolved (including all constraints).
/// Using this callback will cause the world space values to be solved an extra time.
/// Use this callback if want to use bone world space values, and also set bone local values.
/// </summary>
public event UpdateBonesDelegate UpdateWorld { public event UpdateBonesDelegate UpdateWorld {
add { _UpdateWorld += value; } add { _UpdateWorld += value; }
remove { _UpdateWorld -= value; } remove { _UpdateWorld -= value; }
} }
/// <summary>
/// Occurs after the Skeleton's bone world space values are resolved (including all constraints).
/// Use this callback if you want to use bone world space values, but don't intend to modify bone local values.
/// This callback can also be used when setting world position and the bone matrix.
/// </summary>
public event UpdateBonesDelegate UpdateComplete { public event UpdateBonesDelegate UpdateComplete {
add { _UpdateComplete += value; } add { _UpdateComplete += value; }
remove { _UpdateComplete -= value; } remove { _UpdateComplete -= value; }

View File

@ -14,16 +14,30 @@ namespace Spine.Unity {
public enum MixMode { AlwaysMix, MixNext, SpineStyle } public enum MixMode { AlwaysMix, MixNext, SpineStyle }
public MixMode[] layerMixModes = new MixMode[0]; public MixMode[] layerMixModes = new MixMode[0];
/// <summary>
/// Occurs after the animations are applied and before world space values are resolved.
/// Use this callback when you want to set bone local values.
/// </summary>
public event UpdateBonesDelegate UpdateLocal { public event UpdateBonesDelegate UpdateLocal {
add { _UpdateLocal += value; } add { _UpdateLocal += value; }
remove { _UpdateLocal -= value; } remove { _UpdateLocal -= value; }
} }
/// <summary>
/// Occurs after the Skeleton's bone world space values are resolved (including all constraints).
/// Using this callback will cause the world space values to be solved an extra time.
/// Use this callback if want to use bone world space values, and also set bone local values.
/// </summary>
public event UpdateBonesDelegate UpdateWorld { public event UpdateBonesDelegate UpdateWorld {
add { _UpdateWorld += value; } add { _UpdateWorld += value; }
remove { _UpdateWorld -= value; } remove { _UpdateWorld -= value; }
} }
/// <summary>
/// Occurs after the Skeleton's bone world space values are resolved (including all constraints).
/// Use this callback if you want to use bone world space values, but don't intend to modify bone local values.
/// This callback can also be used when setting world position and the bone matrix.
/// </summary>
public event UpdateBonesDelegate UpdateComplete { public event UpdateBonesDelegate UpdateComplete {
add { _UpdateComplete += value; } add { _UpdateComplete += value; }
remove { _UpdateComplete -= value; } remove { _UpdateComplete -= value; }

View File

@ -12,7 +12,6 @@ using UnityEditor;
#else #else
using UnityEditor.AnimatedValues; using UnityEditor.AnimatedValues;
#endif #endif
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Spine; using Spine;
@ -111,12 +110,8 @@ namespace Spine.Unity.Editor {
void UpdateAttachments () { void UpdateAttachments () {
attachmentTable = new Dictionary<Slot, List<Attachment>>(); attachmentTable = new Dictionary<Slot, List<Attachment>>();
Skin skin = skeleton.Skin;
if (skin == null) {
skin = skeletonRenderer.skeletonDataAsset.GetSkeletonData(true).DefaultSkin;
}
Skin skin = skeleton.Skin ?? skeletonRenderer.skeletonDataAsset.GetSkeletonData(true).DefaultSkin;
for (int i = skeleton.Slots.Count-1; i >= 0; i--) { for (int i = skeleton.Slots.Count-1; i >= 0; i--) {
List<Attachment> attachments = new List<Attachment>(); List<Attachment> attachments = new List<Attachment>();
skin.FindAttachmentsForSlot(i, attachments); skin.FindAttachmentsForSlot(i, attachments);
@ -229,14 +224,14 @@ namespace Spine.Unity.Editor {
GUI.contentColor = Color.white; GUI.contentColor = Color.white;
} }
} }
#if UNITY_4_3 #if UNITY_4_3
#else #else
} }
EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndFadeGroup();
if (showSlots.isAnimating) if (showSlots.isAnimating)
Repaint(); Repaint();
#endif #endif
} }
void SpawnHierarchyContextMenu () { void SpawnHierarchyContextMenu () {