mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Spine.Unity and Spine.Unity.Editor namespace
This commit is contained in:
parent
80d8e9e276
commit
9254e18801
@ -38,10 +38,10 @@ using UnityEditor;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
|
|
||||||
[CustomEditor(typeof(AtlasAsset))]
|
[CustomEditor(typeof(AtlasAsset))]
|
||||||
public class AtlasAssetInspector : Editor {
|
public class AtlasAssetInspector : UnityEditor.Editor {
|
||||||
private SerializedProperty atlasFile, materials;
|
private SerializedProperty atlasFile, materials;
|
||||||
private AtlasAsset atlasAsset;
|
private AtlasAsset atlasAsset;
|
||||||
private List<bool> baked;
|
private List<bool> baked;
|
||||||
|
|||||||
@ -14,9 +14,9 @@ using UnityEditor.AnimatedValues;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
[CustomEditor(typeof(SkeletonDataAsset))]
|
[CustomEditor(typeof(SkeletonDataAsset))]
|
||||||
public class SkeletonDataAssetInspector : Editor {
|
public class SkeletonDataAssetInspector : UnityEditor.Editor {
|
||||||
static bool showAnimationStateData = true;
|
static bool showAnimationStateData = true;
|
||||||
static bool showAnimationList = true;
|
static bool showAnimationList = true;
|
||||||
static bool showSlotList = false;
|
static bool showSlotList = false;
|
||||||
@ -50,6 +50,7 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
atlasAssets = serializedObject.FindProperty("atlasAssets");
|
atlasAssets = serializedObject.FindProperty("atlasAssets");
|
||||||
|
atlasAssets.isExpanded = true;
|
||||||
skeletonJSON = serializedObject.FindProperty("skeletonJSON");
|
skeletonJSON = serializedObject.FindProperty("skeletonJSON");
|
||||||
scale = serializedObject.FindProperty("scale");
|
scale = serializedObject.FindProperty("scale");
|
||||||
fromAnimation = serializedObject.FindProperty("fromAnimation");
|
fromAnimation = serializedObject.FindProperty("fromAnimation");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine.Unity.Editor {
|
||||||
public static class AssetDatabaseAvailabilityDetector {
|
public static class AssetDatabaseAvailabilityDetector {
|
||||||
const string MARKER_RESOURCE_NAME = "SpineAssetDatabaseMarker";
|
const string MARKER_RESOURCE_NAME = "SpineAssetDatabaseMarker";
|
||||||
private static bool _isMarkerLoaded;
|
private static bool _isMarkerLoaded;
|
||||||
|
|||||||
@ -33,8 +33,11 @@ using System;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[CustomEditor(typeof(BoneFollower))]
|
|
||||||
public class BoneFollowerInspector : Editor {
|
namespace Spine.Unity.Editor {
|
||||||
|
|
||||||
|
[CustomEditor(typeof(BoneFollower))]
|
||||||
|
public class BoneFollowerInspector : UnityEditor.Editor {
|
||||||
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
|
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
|
||||||
BoneFollower component;
|
BoneFollower component;
|
||||||
bool needsReset;
|
bool needsReset;
|
||||||
@ -84,9 +87,11 @@ public class BoneFollowerInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
||||||
) {
|
) {
|
||||||
component.Reset();
|
component.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ using System.IO;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
public static class Menus {
|
public static class Menus {
|
||||||
[MenuItem("Assets/Create/Spine Atlas")]
|
[MenuItem("Assets/Create/Spine Atlas")]
|
||||||
static public void CreateAtlas () {
|
static public void CreateAtlas () {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ using UnityEditor;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
|
|
||||||
[CustomEditor(typeof(SkeletonAnimation))]
|
[CustomEditor(typeof(SkeletonAnimation))]
|
||||||
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ using System;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
[CustomEditor(typeof(SkeletonAnimator))]
|
[CustomEditor(typeof(SkeletonAnimator))]
|
||||||
public class SkeletonAnimatorInspector : SkeletonRendererInspector {
|
public class SkeletonAnimatorInspector : SkeletonRendererInspector {
|
||||||
protected SerializedProperty layerMixModes;
|
protected SerializedProperty layerMixModes;
|
||||||
|
|||||||
@ -43,12 +43,13 @@ using Spine;
|
|||||||
/// Color Keys (Maybe one day when Unity supports full FBX standard and provides access with code)
|
/// Color Keys (Maybe one day when Unity supports full FBX standard and provides access with code)
|
||||||
/// InheritScale (Never. Unity and Spine do scaling very differently)
|
/// InheritScale (Never. Unity and Spine do scaling very differently)
|
||||||
/// Draw Order Keyframes
|
/// Draw Order Keyframes
|
||||||
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class SkeletonBaker {
|
///
|
||||||
|
namespace Spine.Unity.Editor {
|
||||||
|
public static class SkeletonBaker {
|
||||||
|
|
||||||
#region SkeletonAnimator's Mecanim Clips
|
#region SkeletonAnimator's Mecanim Clips
|
||||||
#if SPINE_SKELETON_ANIMATOR
|
#if SPINE_SKELETON_ANIMATOR
|
||||||
public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonDataAsset) {
|
public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonDataAsset) {
|
||||||
//skeletonDataAsset.Clear();
|
//skeletonDataAsset.Clear();
|
||||||
var data = skeletonDataAsset.GetSkeletonData(true);
|
var data = skeletonDataAsset.GetSkeletonData(true);
|
||||||
@ -60,7 +61,7 @@ public static class SkeletonBaker {
|
|||||||
string dataPath = AssetDatabase.GetAssetPath(skeletonDataAsset);
|
string dataPath = AssetDatabase.GetAssetPath(skeletonDataAsset);
|
||||||
string controllerPath = dataPath.Replace("_SkeletonData", "_Controller").Replace(".asset", ".controller");
|
string controllerPath = dataPath.Replace("_SkeletonData", "_Controller").Replace(".asset", ".controller");
|
||||||
|
|
||||||
#if UNITY_5
|
#if UNITY_5
|
||||||
UnityEditor.Animations.AnimatorController controller;
|
UnityEditor.Animations.AnimatorController controller;
|
||||||
|
|
||||||
if (skeletonDataAsset.controller != null) {
|
if (skeletonDataAsset.controller != null) {
|
||||||
@ -78,7 +79,7 @@ public static class SkeletonBaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UnityEditorInternal.AnimatorController controller;
|
UnityEditorInternal.AnimatorController controller;
|
||||||
|
|
||||||
if (skeletonDataAsset.controller != null) {
|
if (skeletonDataAsset.controller != null) {
|
||||||
@ -95,7 +96,7 @@ public static class SkeletonBaker {
|
|||||||
controller = (UnityEditorInternal.AnimatorController)UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
|
controller = (UnityEditorInternal.AnimatorController)UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
skeletonDataAsset.controller = controller;
|
skeletonDataAsset.controller = controller;
|
||||||
EditorUtility.SetDirty(skeletonDataAsset);
|
EditorUtility.SetDirty(skeletonDataAsset);
|
||||||
@ -129,9 +130,9 @@ public static class SkeletonBaker {
|
|||||||
//generate new dummy clip
|
//generate new dummy clip
|
||||||
AnimationClip newClip = new AnimationClip();
|
AnimationClip newClip = new AnimationClip();
|
||||||
newClip.name = name;
|
newClip.name = name;
|
||||||
#if !(UNITY_5)
|
#if !(UNITY_5)
|
||||||
AnimationUtility.SetAnimationType(newClip, ModelImporterAnimationType.Generic);
|
AnimationUtility.SetAnimationType(newClip, ModelImporterAnimationType.Generic);
|
||||||
#endif
|
#endif
|
||||||
AssetDatabase.AddObjectToAsset(newClip, controller);
|
AssetDatabase.AddObjectToAsset(newClip, controller);
|
||||||
unityAnimationClipTable.Add(name, newClip);
|
unityAnimationClipTable.Add(name, newClip);
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ public static class SkeletonBaker {
|
|||||||
static bool HasFlag (this UnityEngine.Object o, HideFlags flagToCheck) {
|
static bool HasFlag (this UnityEngine.Object o, HideFlags flagToCheck) {
|
||||||
return (o.hideFlags & flagToCheck) == flagToCheck;
|
return (o.hideFlags & flagToCheck) == flagToCheck;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Baking
|
#region Baking
|
||||||
@ -191,32 +192,32 @@ public static class SkeletonBaker {
|
|||||||
|
|
||||||
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
|
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
|
||||||
bool hasAnimations = bakeAnimations && skeletonData.Animations.Count > 0;
|
bool hasAnimations = bakeAnimations && skeletonData.Animations.Count > 0;
|
||||||
#if UNITY_5
|
#if UNITY_5
|
||||||
UnityEditor.Animations.AnimatorController controller = null;
|
UnityEditor.Animations.AnimatorController controller = null;
|
||||||
#else
|
#else
|
||||||
UnityEditorInternal.AnimatorController controller = null;
|
UnityEditorInternal.AnimatorController controller = null;
|
||||||
#endif
|
#endif
|
||||||
if (hasAnimations) {
|
if (hasAnimations) {
|
||||||
string controllerPath = outputPath + "/" + skeletonDataAsset.skeletonJSON.name + " Controller.controller";
|
string controllerPath = outputPath + "/" + skeletonDataAsset.skeletonJSON.name + " Controller.controller";
|
||||||
bool newAnimContainer = false;
|
bool newAnimContainer = false;
|
||||||
|
|
||||||
var runtimeController = AssetDatabase.LoadAssetAtPath(controllerPath, typeof(RuntimeAnimatorController));
|
var runtimeController = AssetDatabase.LoadAssetAtPath(controllerPath, typeof(RuntimeAnimatorController));
|
||||||
|
|
||||||
#if UNITY_5
|
#if UNITY_5
|
||||||
if (runtimeController != null) {
|
if (runtimeController != null) {
|
||||||
controller = (UnityEditor.Animations.AnimatorController)runtimeController;
|
controller = (UnityEditor.Animations.AnimatorController)runtimeController;
|
||||||
} else {
|
} else {
|
||||||
controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
|
controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
|
||||||
newAnimContainer = true;
|
newAnimContainer = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (runtimeController != null) {
|
if (runtimeController != null) {
|
||||||
controller = (UnityEditorInternal.AnimatorController)runtimeController;
|
controller = (UnityEditorInternal.AnimatorController)runtimeController;
|
||||||
} else {
|
} else {
|
||||||
controller = UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
|
controller = UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
|
||||||
newAnimContainer = true;
|
newAnimContainer = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var existingClipTable = new Dictionary<string, AnimationClip>();
|
var existingClipTable = new Dictionary<string, AnimationClip>();
|
||||||
var unusedClipNames = new List<string>();
|
var unusedClipNames = new List<string>();
|
||||||
@ -261,11 +262,11 @@ public static class SkeletonBaker {
|
|||||||
unusedClipNames.Remove(clip.name);
|
unusedClipNames.Remove(clip.name);
|
||||||
} else {
|
} else {
|
||||||
AssetDatabase.AddObjectToAsset(clip, controller);
|
AssetDatabase.AddObjectToAsset(clip, controller);
|
||||||
#if UNITY_5
|
#if UNITY_5
|
||||||
controller.AddMotion(clip);
|
controller.AddMotion(clip);
|
||||||
#else
|
#else
|
||||||
UnityEditorInternal.AnimatorController.AddAnimationClipToController(controller, clip);
|
UnityEditorInternal.AnimatorController.AddAnimationClipToController(controller, clip);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -779,11 +780,11 @@ public static class SkeletonBaker {
|
|||||||
AnimationUtility.SetAnimationEvents(clip, new AnimationEvent[0]);
|
AnimationUtility.SetAnimationEvents(clip, new AnimationEvent[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_5
|
#if UNITY_5
|
||||||
|
|
||||||
#else
|
#else
|
||||||
AnimationUtility.SetAnimationType(clip, ModelImporterAnimationType.Generic);
|
AnimationUtility.SetAnimationType(clip, ModelImporterAnimationType.Generic);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clip.name = name;
|
clip.name = name;
|
||||||
|
|
||||||
@ -1472,15 +1473,18 @@ public static class SkeletonBaker {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
static void SetAnimationSettings (AnimationClip clip, AnimationClipSettings settings) {
|
static void SetAnimationSettings (AnimationClip clip, AnimationClipSettings settings) {
|
||||||
#if UNITY_5
|
#if UNITY_5
|
||||||
AnimationUtility.SetAnimationClipSettings(clip, settings);
|
AnimationUtility.SetAnimationClipSettings(clip, settings);
|
||||||
#else
|
#else
|
||||||
MethodInfo methodInfo = typeof(AnimationUtility).GetMethod("SetAnimationClipSettings", BindingFlags.Static | BindingFlags.NonPublic);
|
MethodInfo methodInfo = typeof(AnimationUtility).GetMethod("SetAnimationClipSettings", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
methodInfo.Invoke(null, new object[] { clip, settings });
|
methodInfo.Invoke(null, new object[] { clip, settings });
|
||||||
|
|
||||||
EditorUtility.SetDirty(clip);
|
EditorUtility.SetDirty(clip);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,10 +33,10 @@ using System;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
|
|
||||||
[CustomEditor(typeof(SkeletonRenderer))]
|
[CustomEditor(typeof(SkeletonRenderer))]
|
||||||
public class SkeletonRendererInspector : Editor {
|
public class SkeletonRendererInspector : UnityEditor.Editor {
|
||||||
protected static bool advancedFoldout;
|
protected static bool advancedFoldout;
|
||||||
|
|
||||||
protected SerializedProperty skeletonDataAsset, initialSkinName, normals, tangents, meshes, immutableTriangles, separatorSlotNames, front, zSpacing;
|
protected SerializedProperty skeletonDataAsset, initialSkinName, normals, tangents, meshes, immutableTriangles, separatorSlotNames, front, zSpacing;
|
||||||
|
|||||||
@ -6,14 +6,12 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
|
namespace Spine.Unity.Editor {
|
||||||
|
public struct SpineDrawerValuePair {
|
||||||
public struct SpineDrawerValuePair {
|
|
||||||
public string str;
|
public string str;
|
||||||
public SerializedProperty property;
|
public SerializedProperty property;
|
||||||
|
|
||||||
@ -21,9 +19,9 @@ public struct SpineDrawerValuePair {
|
|||||||
this.str = val;
|
this.str = val;
|
||||||
this.property = property;
|
this.property = property;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T:SpineAttributeBase {
|
public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T:SpineAttributeBase {
|
||||||
protected SkeletonDataAsset skeletonDataAsset;
|
protected SkeletonDataAsset skeletonDataAsset;
|
||||||
internal const string NoneLabel = "<None>";
|
internal const string NoneLabel = "<None>";
|
||||||
|
|
||||||
@ -93,10 +91,10 @@ public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T:SpineA
|
|||||||
return 18;
|
return 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineSlot))]
|
[CustomPropertyDrawer(typeof(SpineSlot))]
|
||||||
public class SpineSlotDrawer : SpineTreeItemDrawerBase<SpineSlot> {
|
public class SpineSlotDrawer : SpineTreeItemDrawerBase<SpineSlot> {
|
||||||
|
|
||||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) {
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) {
|
||||||
for (int i = 0; i < data.Slots.Count; i++) {
|
for (int i = 0; i < data.Slots.Count; i++) {
|
||||||
@ -133,10 +131,10 @@ public class SpineSlotDrawer : SpineTreeItemDrawerBase<SpineSlot> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineSkin))]
|
[CustomPropertyDrawer(typeof(SpineSkin))]
|
||||||
public class SpineSkinDrawer : SpineTreeItemDrawerBase<SpineSkin> {
|
public class SpineSkinDrawer : SpineTreeItemDrawerBase<SpineSkin> {
|
||||||
|
|
||||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSkin targetAttribute, SkeletonData data) {
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSkin targetAttribute, SkeletonData data) {
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||||
@ -149,10 +147,10 @@ public class SpineSkinDrawer : SpineTreeItemDrawerBase<SpineSkin> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineAnimation))]
|
[CustomPropertyDrawer(typeof(SpineAnimation))]
|
||||||
public class SpineAnimationDrawer : SpineTreeItemDrawerBase<SpineAnimation> {
|
public class SpineAnimationDrawer : SpineTreeItemDrawerBase<SpineAnimation> {
|
||||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAnimation targetAttribute, SkeletonData data) {
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAnimation targetAttribute, SkeletonData data) {
|
||||||
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
|
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
|
||||||
|
|
||||||
@ -166,10 +164,10 @@ public class SpineAnimationDrawer : SpineTreeItemDrawerBase<SpineAnimation> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineEvent))]
|
[CustomPropertyDrawer(typeof(SpineEvent))]
|
||||||
public class SpineEventNameDrawer : SpineTreeItemDrawerBase<SpineEvent> {
|
public class SpineEventNameDrawer : SpineTreeItemDrawerBase<SpineEvent> {
|
||||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineEvent targetAttribute, SkeletonData data) {
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineEvent targetAttribute, SkeletonData data) {
|
||||||
var events = skeletonDataAsset.GetSkeletonData(false).Events;
|
var events = skeletonDataAsset.GetSkeletonData(false).Events;
|
||||||
for (int i = 0; i < events.Count; i++) {
|
for (int i = 0; i < events.Count; i++) {
|
||||||
@ -179,10 +177,10 @@ public class SpineEventNameDrawer : SpineTreeItemDrawerBase<SpineEvent> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineAttachment))]
|
[CustomPropertyDrawer(typeof(SpineAttachment))]
|
||||||
public class SpineAttachmentDrawer : SpineTreeItemDrawerBase<SpineAttachment> {
|
public class SpineAttachmentDrawer : SpineTreeItemDrawerBase<SpineAttachment> {
|
||||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAttachment targetAttribute, SkeletonData data) {
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAttachment targetAttribute, SkeletonData data) {
|
||||||
List<Skin> validSkins = new List<Skin>();
|
List<Skin> validSkins = new List<Skin>();
|
||||||
SkeletonRenderer skeletonRenderer = null;
|
SkeletonRenderer skeletonRenderer = null;
|
||||||
@ -276,10 +274,10 @@ public class SpineAttachmentDrawer : SpineTreeItemDrawerBase<SpineAttachment> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineBone))]
|
[CustomPropertyDrawer(typeof(SpineBone))]
|
||||||
public class SpineBoneDrawer : SpineTreeItemDrawerBase<SpineBone> {
|
public class SpineBoneDrawer : SpineTreeItemDrawerBase<SpineBone> {
|
||||||
|
|
||||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineBone targetAttribute, SkeletonData data) {
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineBone targetAttribute, SkeletonData data) {
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||||
@ -292,10 +290,10 @@ public class SpineBoneDrawer : SpineTreeItemDrawerBase<SpineBone> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineAtlasRegion))]
|
[CustomPropertyDrawer(typeof(SpineAtlasRegion))]
|
||||||
public class SpineAtlasRegionDrawer : PropertyDrawer {
|
public class SpineAtlasRegionDrawer : PropertyDrawer {
|
||||||
Component component;
|
Component component;
|
||||||
SerializedProperty atlasProp;
|
SerializedProperty atlasProp;
|
||||||
|
|
||||||
@ -353,4 +351,6 @@ public class SpineAtlasRegionDrawer : PropertyDrawer {
|
|||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
pair.property.serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
* Spine Editor Utilities created by Mitch Thompson
|
* Spine Editor Utilities created by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
#define SPINE_SKELETONANIMATOR
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -45,8 +46,10 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
[InitializeOnLoad]
|
namespace Spine.Unity.Editor {
|
||||||
public class SpineEditorUtilities : AssetPostprocessor {
|
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class SpineEditorUtilities : AssetPostprocessor {
|
||||||
|
|
||||||
public static class Icons {
|
public static class Icons {
|
||||||
public static Texture2D skeleton;
|
public static Texture2D skeleton;
|
||||||
@ -100,13 +103,13 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
public static Material boneMaterial {
|
public static Material boneMaterial {
|
||||||
get {
|
get {
|
||||||
if (_boneMaterial == null) {
|
if (_boneMaterial == null) {
|
||||||
#if UNITY_4_3
|
#if UNITY_4_3
|
||||||
_boneMaterial = new Material(Shader.Find("Particles/Alpha Blended"));
|
_boneMaterial = new Material(Shader.Find("Particles/Alpha Blended"));
|
||||||
_boneMaterial.SetColor("_TintColor", new Color(0.4f, 0.4f, 0.4f, 0.25f));
|
_boneMaterial.SetColor("_TintColor", new Color(0.4f, 0.4f, 0.4f, 0.25f));
|
||||||
#else
|
#else
|
||||||
_boneMaterial = new Material(Shader.Find("Spine/Bones"));
|
_boneMaterial = new Material(Shader.Find("Spine/Bones"));
|
||||||
_boneMaterial.SetColor("_Color", new Color(0.4f, 0.4f, 0.4f, 0.25f));
|
_boneMaterial.SetColor("_Color", new Color(0.4f, 0.4f, 0.4f, 0.25f));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +194,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Hierarchy Icon
|
||||||
static void HierarchyWindowChanged () {
|
static void HierarchyWindowChanged () {
|
||||||
skeletonRendererTable.Clear();
|
skeletonRendererTable.Clear();
|
||||||
skeletonUtilityBoneTable.Clear();
|
skeletonUtilityBoneTable.Clear();
|
||||||
@ -254,6 +258,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
static void OnPostprocessAllAssets (string[] imported, string[] deleted, string[] moved, string[] movedFromAssetPaths) {
|
static void OnPostprocessAllAssets (string[] imported, string[] deleted, string[] moved, string[] movedFromAssetPaths) {
|
||||||
if (imported.Length == 0)
|
if (imported.Length == 0)
|
||||||
@ -469,14 +474,6 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateMecanimClips (SkeletonDataAsset skeletonDataAsset) {
|
|
||||||
if (skeletonDataAsset.controller == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool CheckForValidAtlas (string atlasPath) {
|
static bool CheckForValidAtlas (string atlasPath) {
|
||||||
return false;
|
return false;
|
||||||
//////////////DEPRECATED - always check for new atlas data now
|
//////////////DEPRECATED - always check for new atlas data now
|
||||||
@ -932,7 +929,8 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)")]
|
#region SkeletonAnimation Menu
|
||||||
|
[MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)", false, 10)]
|
||||||
static void InstantiateSkeletonAnimation () {
|
static void InstantiateSkeletonAnimation () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
foreach (Object o in arr) {
|
foreach (Object o in arr) {
|
||||||
@ -944,7 +942,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)", true)]
|
[MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)", true, 10)]
|
||||||
static bool ValidateInstantiateSkeletonAnimation () {
|
static bool ValidateInstantiateSkeletonAnimation () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
|
|
||||||
@ -1013,8 +1011,18 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
|
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
[MenuItem("Assets/Spine/Instantiate (Mecanim)")]
|
#region SkeletonAnimator
|
||||||
|
#if SPINE_SKELETONANIMATOR
|
||||||
|
static void UpdateMecanimClips (SkeletonDataAsset skeletonDataAsset) {
|
||||||
|
if (skeletonDataAsset.controller == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("Assets/Spine/Instantiate (Mecanim)", false, 100)]
|
||||||
static void InstantiateSkeletonAnimator () {
|
static void InstantiateSkeletonAnimator () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
foreach (Object o in arr) {
|
foreach (Object o in arr) {
|
||||||
@ -1026,7 +1034,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Assets/Spine/Instantiate (SkeletonAnimation)", true)]
|
[MenuItem("Assets/Spine/Instantiate (Mecanim)", true, 100)]
|
||||||
static bool ValidateInstantiateSkeletonAnimator () {
|
static bool ValidateInstantiateSkeletonAnimator () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
|
|
||||||
@ -1099,7 +1107,10 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
|
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Spine Preferences
|
||||||
static bool preferencesLoaded = false;
|
static bool preferencesLoaded = false;
|
||||||
|
|
||||||
[PreferenceItem("Spine")]
|
[PreferenceItem("Spine")]
|
||||||
@ -1127,7 +1138,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
DisableTK2D();
|
DisableTK2D();
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
//TK2D Support
|
//TK2D Support
|
||||||
const string SPINE_TK2D_DEFINE = "SPINE_TK2D";
|
const string SPINE_TK2D_DEFINE = "SPINE_TK2D";
|
||||||
@ -1206,4 +1217,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|||||||
return new BoundingBoxAttachment(name);
|
return new BoundingBoxAttachment(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ using UnityEditor;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity.Editor {
|
||||||
public static class SpineInspectorUtility {
|
public static class SpineInspectorUtility {
|
||||||
|
|
||||||
public static string Pluralize (int n, string singular, string plural) {
|
public static string Pluralize (int n, string singular, string plural) {
|
||||||
@ -100,5 +100,4 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,10 @@ using UnityEngine;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
[CustomEditor(typeof(BoundingBoxFollower))]
|
namespace Spine.Unity.Editor {
|
||||||
public class BoundingBoxFollowerInspector : Editor {
|
|
||||||
|
[CustomEditor(typeof(BoundingBoxFollower))]
|
||||||
|
public class BoundingBoxFollowerInspector : UnityEditor.Editor {
|
||||||
SerializedProperty skeletonRenderer, slotName;
|
SerializedProperty skeletonRenderer, slotName;
|
||||||
BoundingBoxFollower follower;
|
BoundingBoxFollower follower;
|
||||||
bool needToReset = false;
|
bool needToReset = false;
|
||||||
@ -81,4 +83,6 @@ public class BoundingBoxFollowerInspector : Editor {
|
|||||||
collider.enabled = EditorGUILayout.ToggleLeft(new GUIContent(!isPlaceholder ? name : name + " [" + kp.Key.Name + "]", isPlaceholder ? SpineEditorUtilities.Icons.skinPlaceholder : SpineEditorUtilities.Icons.boundingBox), collider.enabled);
|
collider.enabled = EditorGUILayout.ToggleLeft(new GUIContent(!isPlaceholder ? name : name + " [" + kp.Key.Name + "]", isPlaceholder ? SpineEditorUtilities.Icons.skinPlaceholder : SpineEditorUtilities.Icons.boundingBox), collider.enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ using UnityEngine;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine.Unity {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use this as a condition-blocking yield instruction for Unity Coroutines.
|
/// Use this as a condition-blocking yield instruction for Unity Coroutines.
|
||||||
/// The routine will pause until the AnimationState.TrackEntry fires its Complete event.</summary>
|
/// The routine will pause until the AnimationState.TrackEntry fires its Complete event.</summary>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ using UnityEngine;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine.Unity {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use this as a condition-blocking yield instruction for Unity Coroutines.
|
/// Use this as a condition-blocking yield instruction for Unity Coroutines.
|
||||||
/// The routine will pause until the AnimationState fires an event matching the given event name or EventData reference.</summary>
|
/// The routine will pause until the AnimationState fires an event matching the given event name or EventData reference.</summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user