mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-12 18:18:43 +08:00
[unity] More editor improvements.
This commit is contained in:
parent
277f96d50f
commit
3c1894a7d5
@ -52,7 +52,7 @@ namespace Spine.Unity.Editor {
|
||||
if (spriteSlicesLabel == null) {
|
||||
spriteSlicesLabel = new GUIContent(
|
||||
"Apply Regions as Texture Sprite Slices",
|
||||
SpineEditorUtilities.Icons.unityIcon,
|
||||
SpineInspectorUtility.UnityIcon(typeof(SceneAsset)),
|
||||
"Adds Sprite slices to atlas texture(s). " +
|
||||
"Updates existing slices if ones with matching names exist. \n\n" +
|
||||
"If your atlas was exported with Premultiply Alpha, " +
|
||||
|
||||
@ -173,12 +173,12 @@ namespace Spine.Unity.Editor {
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.LabelField("SkeletonData", EditorStyles.boldLabel);
|
||||
// if (m_skeletonData != null) {
|
||||
// var sd = m_skeletonData;
|
||||
// string m = string.Format("{8} - {0} {1}\nBones: {2}\tConstraints: {5} IK + {6} Path + {7} Transform\nSlots: {3}\t\tSkins: {4}\n",
|
||||
// sd.Version, string.IsNullOrEmpty(sd.Version) ? "" : "export", sd.Bones.Count, sd.Slots.Count, sd.Skins.Count, sd.IkConstraints.Count, sd.PathConstraints.Count, sd.TransformConstraints.Count, skeletonJSON.objectReferenceValue.name);
|
||||
// EditorGUILayout.LabelField(new GUIContent("SkeletonData"), new GUIContent("+", m), EditorStyles.boldLabel);
|
||||
// }
|
||||
if (m_skeletonData != null) {
|
||||
var sd = m_skeletonData;
|
||||
string m = string.Format("{8} - {0} {1}\nBones: {2}\nConstraints: \n {5} IK \n {6} Path \n {7} Transform\n\nSlots: {3}\nSkins: {4}\n\nAnimations: {9}",
|
||||
sd.Version, string.IsNullOrEmpty(sd.Version) ? "" : "export ", sd.Bones.Count, sd.Slots.Count, sd.Skins.Count, sd.IkConstraints.Count, sd.PathConstraints.Count, sd.TransformConstraints.Count, skeletonJSON.objectReferenceValue.name, sd.Animations.Count);
|
||||
EditorGUILayout.LabelField(GUIContent.none, new GUIContent(Icons.info, m), GUILayout.Width(30f));
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(skeletonJSON, SpineInspectorUtility.TempContent(skeletonJSON.displayName, Icons.spine));
|
||||
@ -223,8 +223,8 @@ namespace Spine.Unity.Editor {
|
||||
if (m_skeletonData != null) {
|
||||
GUILayout.Space(20f);
|
||||
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
EditorGUILayout.LabelField("Mix Settings", EditorStyles.boldLabel);
|
||||
using (new SpineInspectorUtility.BoxScope(false)) {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Mix Settings", Icons.animationRoot), EditorStyles.boldLabel);
|
||||
DrawAnimationStateInfo();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
@ -259,10 +259,10 @@ namespace Spine.Unity.Editor {
|
||||
void DrawUnityTools () {
|
||||
#if SPINE_SKELETON_ANIMATOR
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
isMecanimExpanded = EditorGUILayout.Foldout(isMecanimExpanded, SpineInspectorUtility.TempContent("SkeletonAnimator", Icons.unityIcon));
|
||||
isMecanimExpanded = EditorGUILayout.Foldout(isMecanimExpanded, SpineInspectorUtility.TempContent("SkeletonAnimator", SpineInspectorUtility.UnityIcon(typeof(SceneAsset))));
|
||||
if (isMecanimExpanded) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(controller, SpineInspectorUtility.TempContent("Controller", Icons.controllerIcon));
|
||||
EditorGUILayout.PropertyField(controller, SpineInspectorUtility.TempContent("Controller", SpineInspectorUtility.UnityIcon(typeof(Animator))));
|
||||
if (controller.objectReferenceValue == null) {
|
||||
|
||||
// Generate Mecanim Controller Button
|
||||
@ -368,26 +368,28 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
void DrawAnimationStateInfo () {
|
||||
showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
|
||||
using (new SpineInspectorUtility.IndentScope())
|
||||
showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
|
||||
|
||||
if (!showAnimationStateData)
|
||||
return;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
SpineInspectorUtility.PropertyFieldWideLabel(defaultMix, DefaultMixLabel, 160);
|
||||
using (new SpineInspectorUtility.IndentScope())
|
||||
SpineInspectorUtility.PropertyFieldWideLabel(defaultMix, DefaultMixLabel, 160);
|
||||
|
||||
var animations = new string[m_skeletonData.Animations.Count];
|
||||
for (int i = 0; i < animations.Length; i++)
|
||||
animations[i] = m_skeletonData.Animations.Items[i].Name;
|
||||
|
||||
// Do not use EditorGUIUtility.indentLevel. It will add spaces on every field.
|
||||
for (int i = 0; i < fromAnimation.arraySize; i++) {
|
||||
SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i);
|
||||
SerializedProperty to = toAnimation.GetArrayElementAtIndex(i);
|
||||
SerializedProperty durationProp = duration.GetArrayElementAtIndex(i);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
from.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)];
|
||||
to.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)];
|
||||
durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue);
|
||||
if (GUILayout.Button("Delete")) {
|
||||
GUILayout.Space(16f);
|
||||
EditorGUILayout.PropertyField(from, GUIContent.none);
|
||||
EditorGUILayout.PropertyField(to, GUIContent.none);
|
||||
durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue, GUILayout.MinWidth(25f), GUILayout.MaxWidth(60f));
|
||||
if (GUILayout.Button("Delete", EditorStyles.miniButton)) {
|
||||
duration.DeleteArrayElementAtIndex(i);
|
||||
toAnimation.DeleteArrayElementAtIndex(i);
|
||||
fromAnimation.DeleteArrayElementAtIndex(i);
|
||||
|
||||
@ -44,7 +44,9 @@ namespace Spine.Unity {
|
||||
public float scale = 0.01f;
|
||||
#endif
|
||||
public TextAsset skeletonJSON;
|
||||
[SpineAnimation(includeNone: false)]
|
||||
public string[] fromAnimation = new string[0];
|
||||
[SpineAnimation(includeNone: false)]
|
||||
public string[] toAnimation = new string[0];
|
||||
public float[] duration = new float[0];
|
||||
public float defaultMix;
|
||||
|
||||
@ -86,7 +86,7 @@ namespace Spine.Unity.Editor {
|
||||
ZSpacingLabel = new GUIContent("Z Spacing", "A value other than 0 adds a space between each rendered attachment to prevent Z Fighting when using shaders that read or write to the depth buffer. Large values may cause unwanted parallax and spaces depending on camera setup.");
|
||||
NormalsLabel = new GUIContent("Add Normals", "Use this if your shader requires vertex normals. A more efficient solution for 2D setups is to modify the shader to assume a single normal value for the whole mesh.");
|
||||
TangentsLabel = new GUIContent("Solve Tangents", "Calculates the tangents per frame. Use this if you are using lit shaders (usually with normal maps) that require vertex tangents.");
|
||||
TintBlackLabel = new GUIContent("Tint Black", "Adds black tint vertex data to the mesh as UV2 and UV3. Black tinting requires that the shader interpret UV2 and UV3 as black tint colors for this effect to work. You may also use the default [Spine/Skeleton Tint Black] shader.\n\nIf you only need to tint the whole skeleton and not individual parts, the [Spine/Skeleton Tint] shader is recommended for better efficiency and changing/animating the _Black material property via MaterialPropertyBlock.");
|
||||
TintBlackLabel = new GUIContent("Tint Black (!)", "Adds black tint vertex data to the mesh as UV2 and UV3. Black tinting requires that the shader interpret UV2 and UV3 as black tint colors for this effect to work. You may also use the default [Spine/Skeleton Tint Black] shader.\n\nIf you only need to tint the whole skeleton and not individual parts, the [Spine/Skeleton Tint] shader is recommended for better efficiency and changing/animating the _Black material property via MaterialPropertyBlock.");
|
||||
SingleSubmeshLabel = new GUIContent("Use Single Submesh", "Simplifies submesh determination by assuming you are only using one Material and need only one submesh. This is will disable render separation and custom slot materials.");
|
||||
|
||||
var so = this.serializedObject;
|
||||
@ -294,8 +294,7 @@ namespace Spine.Unity.Editor {
|
||||
EditorGUILayout.Space();
|
||||
|
||||
using (new SpineInspectorUtility.LabelWidthScope()) {
|
||||
//EditorGUILayout.LabelField("Vertex Data", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Vertex Data", EditorGUIUtility.ObjectContent(null, typeof(MeshFilter)).image as Texture2D), EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Vertex Data", SpineInspectorUtility.UnityIcon(typeof(MeshFilter))), EditorStyles.boldLabel);
|
||||
if (pmaVertexColors != null) EditorGUILayout.PropertyField(pmaVertexColors, PMAVertexColorsLabel);
|
||||
EditorGUILayout.PropertyField(tintBlack, TintBlackLabel);
|
||||
|
||||
|
||||
@ -96,7 +96,8 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
if (skeletonDataAsset == null) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset");
|
||||
return;
|
||||
skeletonDataAsset = property.serializedObject.targetObject as SkeletonDataAsset;
|
||||
if (skeletonDataAsset == null) return;
|
||||
}
|
||||
|
||||
position = EditorGUI.PrefixLabel(position, label);
|
||||
@ -212,8 +213,8 @@ namespace Spine.Unity.Editor {
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAnimation targetAttribute, SkeletonData data) {
|
||||
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
|
||||
|
||||
// <None> item
|
||||
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < animations.Count; i++) {
|
||||
string name = animations.Items[i].Name;
|
||||
@ -232,8 +233,8 @@ namespace Spine.Unity.Editor {
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineEvent targetAttribute, SkeletonData data) {
|
||||
var events = skeletonDataAsset.GetSkeletonData(false).Events;
|
||||
|
||||
// <None> item
|
||||
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < events.Count; i++) {
|
||||
string name = events.Items[i].Name;
|
||||
@ -275,9 +276,12 @@ namespace Spine.Unity.Editor {
|
||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||
|
||||
menu.AddSeparator("");
|
||||
const string NullAttachmentName = "";
|
||||
menu.AddItem(new GUIContent("Null"), property.stringValue == NullAttachmentName, HandleSelect, new SpineDrawerValuePair(NullAttachmentName, property));
|
||||
menu.AddSeparator("");
|
||||
if (TargetAttribute.includeNone) {
|
||||
const string NullAttachmentName = "";
|
||||
menu.AddItem(new GUIContent("Null"), property.stringValue == NullAttachmentName, HandleSelect, new SpineDrawerValuePair(NullAttachmentName, property));
|
||||
menu.AddSeparator("");
|
||||
}
|
||||
|
||||
|
||||
Skin defaultSkin = data.Skins.Items[0];
|
||||
|
||||
@ -337,7 +341,8 @@ namespace Spine.Unity.Editor {
|
||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||
menu.AddSeparator("");
|
||||
|
||||
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < data.Bones.Count; i++) {
|
||||
string name = data.Bones.Items[i].Name;
|
||||
|
||||
@ -79,8 +79,11 @@ namespace Spine.Unity.Editor {
|
||||
public static Texture2D skeletonUtility;
|
||||
public static Texture2D hingeChain;
|
||||
public static Texture2D subMeshRenderer;
|
||||
public static Texture2D unityIcon;
|
||||
public static Texture2D controllerIcon;
|
||||
|
||||
public static Texture2D info;
|
||||
|
||||
// public static Texture2D unityIcon;
|
||||
// public static Texture2D controllerIcon;
|
||||
|
||||
public static void Initialize () {
|
||||
skeleton = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skeleton.png");
|
||||
@ -116,8 +119,9 @@ namespace Spine.Unity.Editor {
|
||||
subMeshRenderer = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-subMeshRenderer.png");
|
||||
path = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-path.png");
|
||||
|
||||
unityIcon = EditorGUIUtility.FindTexture("SceneAsset Icon");
|
||||
controllerIcon = EditorGUIUtility.FindTexture("AnimatorController Icon");
|
||||
info = EditorGUIUtility.FindTexture("console.infoicon.sml");
|
||||
// unityIcon = EditorGUIUtility.FindTexture("SceneAsset Icon");
|
||||
// controllerIcon = EditorGUIUtility.FindTexture("AnimatorController Icon");
|
||||
}
|
||||
|
||||
public static Texture2D GetAttachmentIcon (Attachment attachment) {
|
||||
|
||||
@ -40,6 +40,7 @@ namespace Spine.Unity {
|
||||
public abstract class SpineAttributeBase : PropertyAttribute {
|
||||
public string dataField = "";
|
||||
public string startsWith = "";
|
||||
public bool includeNone = true;
|
||||
}
|
||||
|
||||
public class SpineSlot : SpineAttributeBase {
|
||||
@ -54,10 +55,11 @@ namespace Spine.Unity {
|
||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||
/// </param>
|
||||
/// <param name="containsBoundingBoxes">Disables popup results that don't contain bounding box attachments when true.</param>
|
||||
public SpineSlot(string startsWith = "", string dataField = "", bool containsBoundingBoxes = false) {
|
||||
public SpineSlot(string startsWith = "", string dataField = "", bool containsBoundingBoxes = false, bool includeNone = true) {
|
||||
this.startsWith = startsWith;
|
||||
this.dataField = dataField;
|
||||
this.containsBoundingBoxes = containsBoundingBoxes;
|
||||
this.includeNone = includeNone;
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,9 +72,10 @@ namespace Spine.Unity {
|
||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives).
|
||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||
/// </param>
|
||||
public SpineEvent(string startsWith = "", string dataField = "") {
|
||||
public SpineEvent(string startsWith = "", string dataField = "", bool includeNone = true) {
|
||||
this.startsWith = startsWith;
|
||||
this.dataField = dataField;
|
||||
this.includeNone = includeNone;
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,9 +88,10 @@ namespace Spine.Unity {
|
||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||
/// </param>
|
||||
public SpineSkin(string startsWith = "", string dataField = "") {
|
||||
public SpineSkin(string startsWith = "", string dataField = "", bool includeNone = true) {
|
||||
this.startsWith = startsWith;
|
||||
this.dataField = dataField;
|
||||
this.includeNone = includeNone;
|
||||
}
|
||||
}
|
||||
public class SpineAnimation : SpineAttributeBase {
|
||||
@ -99,9 +103,10 @@ namespace Spine.Unity {
|
||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||
/// </param>
|
||||
public SpineAnimation(string startsWith = "", string dataField = "") {
|
||||
public SpineAnimation(string startsWith = "", string dataField = "", bool includeNone = true) {
|
||||
this.startsWith = startsWith;
|
||||
this.dataField = dataField;
|
||||
this.includeNone = includeNone;
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,12 +127,13 @@ namespace Spine.Unity {
|
||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||
/// </param>
|
||||
public SpineAttachment (bool currentSkinOnly = true, bool returnAttachmentPath = false, bool placeholdersOnly = false, string slotField = "", string dataField = "") {
|
||||
public SpineAttachment (bool currentSkinOnly = true, bool returnAttachmentPath = false, bool placeholdersOnly = false, string slotField = "", string dataField = "", bool includeNone = true) {
|
||||
this.currentSkinOnly = currentSkinOnly;
|
||||
this.returnAttachmentPath = returnAttachmentPath;
|
||||
this.placeholdersOnly = placeholdersOnly;
|
||||
this.slotField = slotField;
|
||||
this.dataField = dataField;
|
||||
this.includeNone = includeNone;
|
||||
}
|
||||
|
||||
public static SpineAttachment.Hierarchy GetHierarchy (string fullPath) {
|
||||
@ -183,9 +189,10 @@ namespace Spine.Unity {
|
||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||
/// </param>
|
||||
public SpineBone(string startsWith = "", string dataField = "") {
|
||||
public SpineBone(string startsWith = "", string dataField = "", bool includeNone = true) {
|
||||
this.startsWith = startsWith;
|
||||
this.dataField = dataField;
|
||||
this.includeNone = includeNone;
|
||||
}
|
||||
|
||||
public static Spine.Bone GetBone(string boneName, SkeletonRenderer renderer) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user