mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Fix SpineAttributes not seeing sibling fields in arrays and serialized structs/classes.
This commit is contained in:
parent
f9c04584c3
commit
3fe876adcd
@ -74,7 +74,7 @@ namespace Spine.Unity.Editor {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataField = property.serializedObject.FindProperty(TargetAttribute.dataField);
|
||||
var dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField);
|
||||
if (dataField != null) {
|
||||
if (dataField.objectReferenceValue is SkeletonDataAsset) {
|
||||
skeletonDataAsset = (SkeletonDataAsset)dataField.objectReferenceValue;
|
||||
@ -108,7 +108,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
public ISkeletonComponent GetTargetSkeletonComponent (SerializedProperty property) {
|
||||
var dataField = property.serializedObject.FindProperty(TargetAttribute.dataField);
|
||||
var dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField);
|
||||
|
||||
if (dataField != null) {
|
||||
var skeletonComponent = dataField.objectReferenceValue as ISkeletonComponent;
|
||||
@ -282,10 +282,9 @@ namespace Spine.Unity.Editor {
|
||||
menu.AddSeparator("");
|
||||
}
|
||||
|
||||
|
||||
Skin defaultSkin = data.Skins.Items[0];
|
||||
var slotProperty = property.FindBaseOrSiblingProperty(TargetAttribute.slotField);
|
||||
|
||||
SerializedProperty slotProperty = property.serializedObject.FindProperty(targetAttribute.slotField);
|
||||
string slotMatch = "";
|
||||
if (slotProperty != null) {
|
||||
if (slotProperty.propertyType == SerializedPropertyType.String)
|
||||
@ -369,7 +368,7 @@ namespace Spine.Unity.Editor {
|
||||
if (string.IsNullOrEmpty(atlasAssetFieldName))
|
||||
atlasAssetFieldName = "atlasAsset";
|
||||
|
||||
atlasProp = property.serializedObject.FindProperty(atlasAssetFieldName);
|
||||
atlasProp = property.FindBaseOrSiblingProperty(atlasAssetFieldName);
|
||||
|
||||
if (atlasProp == null) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Must have AtlasAsset variable!");
|
||||
|
||||
@ -79,6 +79,20 @@ namespace Spine.Unity.Editor {
|
||||
return EditorGUIUtility.ObjectContent(null, type).image as Texture2D;
|
||||
}
|
||||
|
||||
#region SerializedProperty Helpers
|
||||
public static SerializedProperty FindBaseOrSiblingProperty (this SerializedProperty property, string propertyName) {
|
||||
if (string.IsNullOrEmpty(propertyName)) return null;
|
||||
SerializedProperty relativeProperty = property.serializedObject.FindProperty(propertyName); // baseProperty
|
||||
if (relativeProperty == null) { // If no baseProperty, find sibling property.
|
||||
int nameLength = property.name.Length;
|
||||
string propertyPath = property.propertyPath;
|
||||
propertyPath = propertyPath.Remove(propertyPath.Length - nameLength, nameLength) + propertyName;
|
||||
relativeProperty = property.serializedObject.FindProperty(propertyPath);
|
||||
}
|
||||
return relativeProperty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Layout Scopes
|
||||
static GUIStyle grayMiniLabel;
|
||||
public static GUIStyle GrayMiniLabel {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user