From 533a25286a621b2b3c7180f0e0f9635897a55ffd Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 19 Nov 2018 11:07:24 +0800 Subject: [PATCH] [unity] SpineEvent attribute audioOnly flag. --- .../spine-unity/Editor/SpineAttributeDrawers.cs | 13 +++++++++---- .../Spine/Runtime/spine-unity/SpineAttributes.cs | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs index 1ac54a275..651d1c0b9 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs @@ -158,7 +158,7 @@ namespace Spine.Unity.Editor { protected virtual void HandleSelect (object menuItemObject) { var clickedItem = (SpineDrawerValuePair)menuItemObject; var serializedProperty = clickedItem.property; - if (serializedProperty.serializedObject.isEditingMultipleObjects) serializedProperty.stringValue = "oaifnoiasf°ñ123526"; // HACK: to trigger change on multi-editing. + if (serializedProperty.serializedObject.isEditingMultipleObjects) serializedProperty.stringValue = "oaifnoiasf°ñ123526"; // HACK: to trigger change on multi-editing. serializedProperty.stringValue = clickedItem.stringValue; serializedProperty.serializedObject.ApplyModifiedProperties(); } @@ -336,9 +336,14 @@ namespace Spine.Unity.Editor { menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property)); for (int i = 0; i < events.Count; i++) { - string name = events.Items[i].Name; - if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) - menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); + var eventObject = events.Items[i]; + string name = eventObject.Name; + if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) { + if (!TargetAttribute.audioOnly || !string.IsNullOrEmpty(eventObject.AudioPath)) { + menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); + } + } + } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs index c6bf39d8e..97e0efe87 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs @@ -123,11 +123,15 @@ 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. /// /// If true, and an animation list source can't be found, the field will fall back to a normal text field. If false, it will show an error. - public SpineEvent (string startsWith = "", string dataField = "", bool includeNone = true, bool fallbackToTextField = false) { + + public bool audioOnly = false; + + public SpineEvent (string startsWith = "", string dataField = "", bool includeNone = true, bool fallbackToTextField = false, bool audioOnly = false) { this.startsWith = startsWith; this.dataField = dataField; this.includeNone = includeNone; this.fallbackToTextField = fallbackToTextField; + this.audioOnly = audioOnly; } }