[unity] SpineEvent attribute audioOnly flag.

This commit is contained in:
pharan 2018-11-19 11:07:24 +08:00
parent 12e7ebf78f
commit 533a25286a
2 changed files with 14 additions and 5 deletions

View File

@ -158,7 +158,7 @@ namespace Spine.Unity.Editor {
protected virtual void HandleSelect (object menuItemObject) { protected virtual void HandleSelect (object menuItemObject) {
var clickedItem = (SpineDrawerValuePair)menuItemObject; var clickedItem = (SpineDrawerValuePair)menuItemObject;
var serializedProperty = clickedItem.property; 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.stringValue = clickedItem.stringValue;
serializedProperty.serializedObject.ApplyModifiedProperties(); 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)); 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++) { for (int i = 0; i < events.Count; i++) {
string name = events.Items[i].Name; var eventObject = events.Items[i];
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) string name = eventObject.Name;
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); 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));
}
}
} }
} }

View File

@ -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 left empty and the script the attribute is applied to is derived from Component, GetComponent(SkeletonRenderer)() will be called as a fallback.
/// </param> /// </param>
/// <param name="fallbackToTextField">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.</param> /// <param name="fallbackToTextField">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.</param>
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.startsWith = startsWith;
this.dataField = dataField; this.dataField = dataField;
this.includeNone = includeNone; this.includeNone = includeNone;
this.fallbackToTextField = fallbackToTextField; this.fallbackToTextField = fallbackToTextField;
this.audioOnly = audioOnly;
} }
} }